Skip to content

Commit

Permalink
fix: multi-arch digest issue (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
hel-kame authored Jul 24, 2024
1 parent 6622563 commit e994ed2
Showing 1 changed file with 11 additions and 62 deletions.
73 changes: 11 additions & 62 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e994ed2

Please sign in to comment.