From 303aeb05266818582a164f1b558b06a0ff146b7a Mon Sep 17 00:00:00 2001 From: Kevin Meinhardt Date: Wed, 26 Jun 2024 10:59:53 +0200 Subject: [PATCH] TMP: push artifact --- .github/actions/build/action.yml | 53 +++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 374423a..a3b68ba 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -46,16 +46,6 @@ runs: version: latest buildkitd-flags: --debug - # Login to a registry to push the image - - name: Login to Container Registry - # Only login if we are pushing the image - if: ${{ inputs.push == 'true' }} - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ inputs.username }} - password: ${{ inputs.password }} - - name: Docker Image id: image shell: bash @@ -100,6 +90,12 @@ runs: cat $GITHUB_OUTPUT + - name: Tar file + id: tar + shell: bash + run: | + echo "path=/tmp/image.tar" >> $GITHUB_OUTPUT + - name: Build Image id: build uses: docker/bake-action@v4 @@ -107,8 +103,37 @@ runs: DOCKER_TAG: ${{ steps.tag.outputs.tag }} with: targets: app - push: ${{ inputs.push }} - load: ${{ inputs.push == 'false' }} set: | - *.cache-from=type=registry,ref=${{ steps.tag.outputs.tag_cache }} - *.cache-to=type=registry,ref=${{ steps.tag.outputs.tag_cache }},mode=max,compression-level=9,force-compression=true,ignore-error=true + *.output=type=docker,dest=${{ steps.tar.outputs.path }} + + - name: Get image digest + id: digest + shell: bash + run: | + echo '${{ steps.build.outputs.metadata }}' > metadata.json + echo "digest=$(cat metadata.json | jq -r '.app."containerimage.digest"')" >> $GITHUB_OUTPUT + cat $GITHUB_OUTPUT + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.digest.outputs.digest }} + path: ${{ steps.tar.outputs.path }} + retention-days: 1 + compression-level: 9 + overwrite: true + + - name: Login to Container Registry + if: inputs.push == 'true' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ inputs.username }} + password: ${{ inputs.password }} + + - name: Push Image + if: inputs.push == 'true' + shell: bash + run: | + docker load < ${{ steps.tar.outputs.path }} + docker image push --all-tags ${{ steps.image.outputs.image }}