Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multi-arch digest issue #35

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading