Skip to content

Commit fdc4842

Browse files
try using manifest
1 parent f935aba commit fdc4842

1 file changed

Lines changed: 49 additions & 16 deletions

File tree

.github/workflows/build.yml

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
build:
1414
runs-on: ${{ matrix.runner }}
1515
outputs:
16-
build-image-arm: ${{ steps.gen-output.outputs.image-arm }}
17-
build-image-x86: ${{ steps.gen-output.outputs.image-x86 }}
16+
build-image-arm: ${{ steps.gen-output.outputs.image-arm64 }}
17+
build-image-x64: ${{ steps.gen-output.outputs.image-x64 }}
1818
strategy:
1919
fail-fast: false
2020
matrix:
@@ -44,34 +44,67 @@ jobs:
4444
with:
4545
images: ${{ github.repository }}
4646

47-
- name: Write arch-specific image digest to outputs
48-
id: gen-output
49-
run: |
50-
arch="${RUNNER_ARCH,,}"
51-
echo $arch
52-
fail
53-
54-
# echo "image-${{ runner.arch == 'X86' && 'x86' || 'arm' }}=${{ steps.meta.outputs.images }}@${{ steps.build.outputs.digest }}" >> "$GITHUB_OUTPUT"
5547
- name: Build/push the arm image
5648
id: build
5749
uses: docker/build-push-action@v6
5850
with:
51+
# @note GHA caching needs tuning, these tend not to hit. Perhaps switch to type=registry?
5952
cache-from: type=gha
6053
cache-to: type=gha,mode=max
6154
labels: ${{ steps.meta.outputs.labels }}
62-
platforms: local
6355
provenance: true
6456
sbom: true
6557
tags: ${{ steps.meta.outputs.tags }}
66-
outputs: push-by-digest=true,type=image,push=true
58+
outputs: type=image,push-by-digest=true,push=true
6759

68-
test:
60+
- name: Write arch-specific image digest to outputs
61+
id: gen-output
62+
run: |
63+
echo "image-${RUNNER_ARCH,,}=${{ steps.meta.outputs.tags }}@${{ steps.build.outputs.digest }}" | tee -a "$GITHUB_OUTPUT"
64+
65+
merge:
6966
runs-on: ubuntu-24.04
7067
needs:
7168
- build
69+
outputs:
70+
build-image: ${{ steps.meta.outputs.tags }}
71+
env:
72+
DOCKER_APP_IMAGE_ARM64: ${{ needs.build.outputs.build-image-arm }}
73+
DOCKER_APP_IMAGE_X64: ${{ needs.build.outputs.build-image-x64 }}
74+
steps:
75+
- name: Checkout code
76+
uses: actions/checkout@v4
77+
78+
- name: Login to GitHub Container Registry
79+
uses: docker/login-action@v3
80+
with:
81+
registry: ghcr.io
82+
username: ${{ github.actor }}
83+
password: ${{ secrets.GITHUB_TOKEN }}
84+
85+
- name: Docker meta
86+
id: meta
87+
uses: docker/metadata-action@v5
88+
with:
89+
images: ${{ github.repository }}
90+
tags: |
91+
type=sha,suffix=-build-${{ github.run_id }}_${{ github.run_attempt }}
92+
93+
- name: Push the multi-platform image
94+
run: |
95+
docker manifest create \
96+
--amend "$DOCKER_APP_IMAGE_ARM64" \
97+
--amend "$DOCKER_APP_IMAGE_X64" \
98+
${{ steps.meta.outputs.tags }}
99+
docker manifest push ${{ steps.meta.outputs.tags }}
100+
101+
test:
102+
runs-on: ubuntu-24.04
103+
needs:
104+
- merge
72105
env:
73106
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml
74-
DOCKER_APP_IMAGE: ${{ needs.build.outputs.build-image-x86 }}
107+
DOCKER_APP_IMAGE: ${{ needs.merge.outputs.build-image }}
75108
steps:
76109
- name: Checkout code
77110
uses: actions/checkout@v4
@@ -95,10 +128,10 @@ jobs:
95128
push:
96129
runs-on: ubuntu-24.04
97130
needs:
98-
- build
131+
- merge
99132
- test
100133
env:
101-
DOCKER_APP_IMAGE: ${{ needs.build.outputs.build-image-x86 }}
134+
DOCKER_APP_IMAGE: ${{ needs.merge.outputs.build-image }}
102135
steps:
103136
- name: Checkout code
104137
uses: actions/checkout@v4

0 commit comments

Comments
 (0)