Skip to content

Commit e135b28

Browse files
committed
fix: multi-arch builds
1 parent 1be9ed3 commit e135b28

1 file changed

Lines changed: 62 additions & 5 deletions

File tree

.github/workflows/build.yaml

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ jobs:
3737
uses: docker/metadata-action@v5
3838
with:
3939
images: ${{ env.IMAGE_NAME }}
40+
tags: |
41+
type=ref,event=branch
42+
type=semver,pattern={{version}}
43+
type=semver,pattern={{major}}.{{minor}}
44+
4045
- uses: actions/checkout@v3
4146
- name: Login to ghcr
4247
uses: docker/login-action@v3
@@ -58,17 +63,69 @@ jobs:
5863
context: .
5964
file: Dockerfile
6065
outputs: type=docker
66+
labels: ${{ steps.meta.outputs.labels }}
6167
platforms: ${{ matrix.platform }}
62-
push: ${{ github.event_name == 'push' }}
68+
tags: ${{ steps.meta.outputs.tags }}
69+
- name: Export digest
70+
if: ${{ github.event_name == 'push' }}
71+
run: |
72+
mkdir -p ${{ runner.temp }}/digests
73+
digest="${{ steps.build.outputs.digest }}"
74+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
75+
- name: Upload digest
76+
uses: actions/upload-artifact@v4
77+
if: ${{ github.event_name == 'push' }}
78+
with:
79+
name: digests-${{ env.PLATFORM_PAIR }}
80+
path: ${{ runner.temp }}/digests/*
81+
if-no-files-found: error
82+
retention-days: 1
83+
merge:
84+
runs-on: ubuntu-24.04
85+
if: ${{ github.event_name == 'push' }}
86+
needs:
87+
- build
88+
steps:
89+
- name: Download digests
90+
uses: actions/download-artifact@v4
91+
with:
92+
path: ${{ runner.temp }}/digests
93+
pattern: digests-*
94+
merge-multiple: true
95+
96+
- name: Login to Docker Hub
97+
uses: docker/login-action@v3
98+
with:
99+
username: ${{ vars.DOCKERHUB_USERNAME }}
100+
password: ${{ secrets.DOCKERHUB_TOKEN }}
101+
102+
- name: Set up Docker Buildx
103+
uses: docker/setup-buildx-action@v3
104+
105+
- name: Docker meta
106+
id: meta
107+
uses: docker/metadata-action@v5
108+
with:
109+
images: ${{ env.IMAGE_NAME }}
63110
tags: |
64-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.sync_version }}
65-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
111+
type=ref,event=branch
112+
type=ref,event=pr
113+
type=semver,pattern={{version}}
114+
type=semver,pattern={{major}}.{{minor}}
115+
66116
- name: Attest
67117
uses: actions/attest-build-provenance@v2
68-
if: ${{ github.event_name == 'push' }}
69118
with:
70119
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
71120
subject-digest: ${{ steps.build.outputs.digest }}
72121
push-to-registry: true
73122

74-
123+
- name: Create manifest list and push
124+
working-directory: ${{ runner.temp }}/digests
125+
run: |
126+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
127+
$(printf '${{ env.IMAGE_NAME }}@sha256:%s ' *)
128+
129+
- name: Inspect image
130+
run: |
131+
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)