From e994ed286eb4b5f6b9161ac4880ad41a91271594 Mon Sep 17 00:00:00 2001 From: hithem <117039823+hel-kame@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:50:04 +0200 Subject: [PATCH] fix: multi-arch digest issue (#35) --- .github/workflows/docker-build.yml | 73 +++++------------------------- 1 file changed, 11 insertions(+), 62 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 9a1a3d6..db6618d 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -19,61 +19,11 @@ env: REGISTRY_IMAGE: ghcr.io/${{ github.repository }} jobs: - build-amd64: + build: runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY_IMAGE }} - tags: | - type=raw,value=${{ inputs.release_tag_name }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - id: build-amd64 - uses: docker/build-push-action@v6 - with: - context: . - file: Dockerfile - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-amd64 - cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-amd64,mode=max - outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true - - - name: Export digests - run: | - mkdir -p /tmp/digests - digest="${{ steps.build-amd64.outputs.digest }}" - touch "/tmp/digests/${digest#sha256:}" - - - name: Upload digest - uses: actions/upload-artifact@v3 - with: - name: digests - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - - build-arm64: - runs-on: ubuntu-latest - + strategy: + matrix: + platform: [amd64, arm64] steps: - name: Checkout uses: actions/checkout@v4 @@ -92,7 +42,7 @@ jobs: uses: docker/setup-qemu-action@v3 with: image: tonistiigi/binfmt:latest - platforms: linux/amd64,linux/arm64 + platforms: ${{ format('linux/{0}', matrix.platform) }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -105,21 +55,21 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - id: build-arm64 + id: build uses: docker/build-push-action@v6 with: context: . file: Dockerfile - platforms: linux/arm64 + platforms: ${{ format('linux/{0}', matrix.platform) }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-arm64 - cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-arm64,mode=max + cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-${{ matrix.platform }},mode=max + cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-${{ matrix.platform }},mode=max outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true - name: Export digest run: | mkdir -p /tmp/digests - digest="${{ steps.build-arm64.outputs.digest }}" + digest="${{ steps.build.outputs.digest }}" touch "/tmp/digests/${digest#sha256:}" - name: Upload digest @@ -133,8 +83,7 @@ jobs: merge: runs-on: ubuntu-latest needs: - - build-amd64 - - build-arm64 + - build steps: - name: Download digests uses: actions/download-artifact@v3