From 6ad2aeef55e30aa0b26971e121ea6fe6a91ea8de Mon Sep 17 00:00:00 2001 From: sveitser Date: Thu, 8 Aug 2024 12:33:35 +0200 Subject: [PATCH 1/3] Save digest artifacts into own directory per run Currently it seems that we have too many digests in the folder and I think this breaks the assembly of the multiarch docker image. With this change only digests for the same run are saved in the same directory. --- .github/actions/docker-image/action.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/actions/docker-image/action.yml b/.github/actions/docker-image/action.yml index f0cc8ac781..2abd3952ee 100644 --- a/.github/actions/docker-image/action.yml +++ b/.github/actions/docker-image/action.yml @@ -44,10 +44,13 @@ runs: cache-to: type=gha,mode=max outputs: type=image,name=${{ inputs.images }},push-by-digest=true,name-canonical=true,push=true + # This will upload the digest for each architecture to the same artifact, + # Note: upload-artifact@v4 will no longer support this. + # https://github.com/actions/upload-artifact?tab=readme-ov-file#not-uploading-to-the-same-artifact - name: Export digest shell: bash run: | - digest_dir="${{ runner.temp }}/${{ inputs.target }}-digests" + digest_dir="${{ runner.temp }}/${{ inputs.target }}-${{ github.run_number }}-digests" mkdir -p "${digest_dir}" digest="${{ steps.build.outputs.digest }}" touch "${digest_dir}/${digest#sha256:}" @@ -56,6 +59,6 @@ runs: uses: actions/upload-artifact@v3 with: name: "${{ inputs.target }}-digests" - path: "${{ runner.temp }}/${{ inputs.target }}-digests/*" + path: "${{ runner.temp }}/${{ inputs.target }}-${{ github.run_number }}-digests/*" if-no-files-found: error retention-days: 1 From 5544831b2965f957fc99166304bac805c077d354 Mon Sep 17 00:00:00 2001 From: sveitser Date: Thu, 8 Aug 2024 15:29:04 +0200 Subject: [PATCH 2/3] Fail docker image merge on wrong number of digests [ci skip] --- .github/workflows/espresso-docker.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/espresso-docker.yml b/.github/workflows/espresso-docker.yml index 3bb007c750..15965c3c54 100644 --- a/.github/workflows/espresso-docker.yml +++ b/.github/workflows/espresso-docker.yml @@ -161,6 +161,16 @@ jobs: - name: Create manifest list and push working-directory: "${{ runner.temp }}/digests" run: | + # Count the number of files in the directory + file_count=$(find . -type f | wc -l) + + ls -lah + + if [ "$file_count" -ne 2 ]; then + echo "Should have exactly 2 digests to combine, something went wrong" + exit 1 + fi + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ $(printf '${{ matrix.image }}@sha256:%s ' *) - name: Inspect image From ad339ce4b86e9f4060e19f25a43aeedc9a130267 Mon Sep 17 00:00:00 2001 From: sveitser Date: Thu, 8 Aug 2024 15:41:10 +0200 Subject: [PATCH 3/3] Clean digests dir [ci skip] --- .github/workflows/espresso-docker.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/espresso-docker.yml b/.github/workflows/espresso-docker.yml index 15965c3c54..7c595cf93e 100644 --- a/.github/workflows/espresso-docker.yml +++ b/.github/workflows/espresso-docker.yml @@ -146,6 +146,10 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Remove digests dir + run: | + rm -rf "${{ runner.temp }}/digests" + - name: Download digests uses: actions/download-artifact@v3 with: @@ -164,10 +168,9 @@ jobs: # Count the number of files in the directory file_count=$(find . -type f | wc -l) - ls -lah - if [ "$file_count" -ne 2 ]; then echo "Should have exactly 2 digests to combine, something went wrong" + ls -lah exit 1 fi