Skip to content

Commit 860f9ea

Browse files
Copilotcardil
andauthored
Fix multi-arch workflow: build and push the manifest with explicit buildah/podman steps (#7)
* Initial plan * Fix multiarch workflow: explicit manifest build/push Co-authored-by: cardil <540893+cardil@users.noreply.github.com> * Restore redhat-actions; pin buildah-build to main with inspect fix Co-authored-by: cardil <540893+cardil@users.noreply.github.com> * Reference upstream fix PR #207 in workflow comment Co-authored-by: cardil <540893+cardil@users.noreply.github.com> * Use fully qualified image name; push to ttl.sh outside master Co-authored-by: cardil <540893+cardil@users.noreply.github.com> * Unpin buildah-build to v3; use ttl.sh/wavesoftware registry Co-authored-by: cardil <540893+cardil@users.noreply.github.com> * Build only localhost/php:latest; drop added comment Co-authored-by: cardil <540893+cardil@users.noreply.github.com> * Push existing local tag (latest) to ttl.sh Co-authored-by: cardil <540893+cardil@users.noreply.github.com> * Build amd64/arm64 natively in a matrix and combine into one manifest Co-authored-by: cardil <540893+cardil@users.noreply.github.com> * Tag PR builds as pr-<number> instead of latest Co-authored-by: cardil <540893+cardil@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: cardil <540893+cardil@users.noreply.github.com>
1 parent 60a7de6 commit 860f9ea

1 file changed

Lines changed: 58 additions & 20 deletions

File tree

‎.github/workflows/multiarch-build.yaml‎

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,78 @@ name: Multiarch build
33
on:
44
push:
55
branches:
6-
- '**'
6+
- master
7+
pull_request: {} # PR builds are tagged pr-<number>
78
schedule:
89
# Every month's 2nd on 5:30
910
- cron: '30 5 2 * *'
1011
workflow_dispatch: {} # allow manual trigger
1112

13+
env:
14+
# master publishes :latest, PRs publish :pr-<number> so parallel PRs don't interfere
15+
TAG: ${{ github.ref == 'refs/heads/master' && 'latest' || format('pr-{0}', github.event.number || github.run_id) }}
16+
# master publishes to quay.io, other refs to the ephemeral ttl.sh registry
17+
REGISTRY: ${{ github.ref == 'refs/heads/master' && 'quay.io/wavesoftware' || 'ttl.sh/wavesoftware' }}
18+
1219
jobs:
13-
multiarch-build:
14-
name: Build images
15-
runs-on: ubuntu-24.04
20+
build:
21+
name: Build ${{ matrix.arch }} image
22+
runs-on: ${{ matrix.runner }}
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- arch: amd64
28+
runner: ubuntu-24.04
29+
- arch: arm64
30+
runner: ubuntu-24.04-arm
1631
steps:
1732
- uses: actions/checkout@v7
1833

19-
- name: Install qemu dependency
20-
run: |
21-
sudo apt-get update
22-
sudo apt-get install -y qemu-user-static
23-
34+
# Native build on each architecture, no QEMU emulation needed
2435
- name: Buildah Action
2536
id: build-image
2637
uses: redhat-actions/buildah-build@v3
2738
with:
28-
image: php
29-
tags: latest
30-
platforms: linux/amd64, linux/arm64
39+
tags: localhost/php:${{ env.TAG }}-${{ matrix.arch }}
40+
platforms: linux/${{ matrix.arch }}
3141
containerfiles: Containerfile
3242

33-
- name: Push To quay.io
34-
id: push-to-quay
43+
- name: Push per-arch image
44+
id: push-image
3545
uses: redhat-actions/push-to-registry@v3
36-
if: github.ref == 'refs/heads/master'
3746
with:
38-
image: ${{ steps.build-image.outputs.image }}
39-
tags: ${{ steps.build-image.outputs.tags }}
40-
registry: quay.io/wavesoftware
41-
username: ${{ secrets.QUAY_USER }}
42-
password: ${{ secrets.QUAY_PASSWORD }}
47+
image: php
48+
tags: ${{ env.TAG }}-${{ matrix.arch }}
49+
registry: ${{ env.REGISTRY }}
50+
username: ${{ github.ref == 'refs/heads/master' && secrets.QUAY_USER || '' }}
51+
password: ${{ github.ref == 'refs/heads/master' && secrets.QUAY_PASSWORD || '' }}
52+
53+
manifest:
54+
name: Combine into multi-arch image
55+
runs-on: ubuntu-24.04
56+
needs: build
57+
steps:
58+
- name: Log in to quay.io
59+
if: github.ref == 'refs/heads/master'
60+
env:
61+
QUAY_USER: ${{ secrets.QUAY_USER }}
62+
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
63+
run: |
64+
buildah login --username "${QUAY_USER}" --password-stdin quay.io <<< "${QUAY_PASSWORD}"
65+
66+
- name: Create and push manifest list
67+
run: |
68+
set -euo pipefail
69+
image="${REGISTRY}/php"
70+
buildah manifest create php:${TAG}
71+
for arch in amd64 arm64; do
72+
buildah manifest add php:${TAG} "docker://${image}:${TAG}-${arch}"
73+
done
74+
count=$(buildah manifest inspect php:${TAG} | jq '.manifests | length')
75+
if [ "${count}" -ne 2 ]; then
76+
echo "::error::Expected 2 images in manifest, found ${count}"
77+
buildah manifest inspect php:${TAG}
78+
exit 1
79+
fi
80+
buildah manifest push --all php:${TAG} "docker://${image}:${TAG}"

0 commit comments

Comments
 (0)