@@ -14,57 +14,119 @@ permissions:
1414 contents : read
1515 packages : write
1616
17+ env :
18+ REGISTRY : ghcr.io
19+ OWNER : static-php
20+
1721jobs :
1822 build :
19- runs-on : ubuntu-24.04
23+ name : Build (${{ matrix.image.name }} ${{ matrix.platform.arch }})
2024 strategy :
2125 fail-fast : false
2226 matrix :
23- include :
27+ image :
2428 - dockerfile : Dockerfile.debian
25- image : packages-builder-debian
29+ name : packages-builder-debian
2630 build-args : " "
2731 - dockerfile : Dockerfile.alpine
28- image : packages-builder-alpine
32+ name : packages-builder-alpine
2933 build-args : " "
3034 - dockerfile : Dockerfile.rhel
31- image : packages-builder-rhel-8
35+ name : packages-builder-rhel-8
3236 build-args : " ALMA_VERSION=8"
3337 - dockerfile : Dockerfile.rhel
34- image : packages-builder-rhel-9
38+ name : packages-builder-rhel-9
3539 build-args : " ALMA_VERSION=9"
3640 - dockerfile : Dockerfile.rhel
37- image : packages-builder-rhel-10
41+ name : packages-builder-rhel-10
3842 build-args : " ALMA_VERSION=10"
43+ platform :
44+ - arch : amd64
45+ runs-on : ubuntu-24.04
46+ - arch : arm64
47+ runs-on : ubuntu-24.04-arm
48+ runs-on : ${{ matrix.platform.runs-on }}
3949 steps :
4050 - name : Checkout
4151 uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
4252 with :
4353 persist-credentials : false
4454
45- - name : Set up QEMU
46- uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
47-
4855 - name : Set up Docker Buildx
4956 uses : docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
5057
5158 - name : Log in to GHCR
5259 uses : docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
5360 with :
54- registry : ghcr.io
61+ registry : ${{ env.REGISTRY }}
5562 username : ${{ github.actor }}
5663 password : ${{ secrets.GITHUB_TOKEN }}
5764
58- - name : Build and push ${{ matrix.image }}
65+ - name : Build and push by digest
66+ id : build
5967 uses : docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6
6068 with :
6169 context : .
62- file : ${{ matrix.dockerfile }}
63- platforms : linux/amd64,linux/arm64
64- push : true
65- tags : |
66- ghcr.io/static-php/${{ matrix.image }}:latest
67- ghcr.io/static-php/${{ matrix.image }}:${{ github.sha }}
68- build-args : ${{ matrix.build-args }}
69- cache-from : type=gha,scope=${{ matrix.image }}
70- cache-to : type=gha,scope=${{ matrix.image }},mode=max
70+ file : ${{ matrix.image.dockerfile }}
71+ platforms : linux/${{ matrix.platform.arch }}
72+ build-args : ${{ matrix.image.build-args }}
73+ cache-from : type=gha,scope=${{ matrix.image.name }}-${{ matrix.platform.arch }}
74+ cache-to : type=gha,scope=${{ matrix.image.name }}-${{ matrix.platform.arch }},mode=max
75+ outputs : type=image,name=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ matrix.image.name }},push-by-digest=true,name-canonical=true,push=true
76+
77+ - name : Export digest
78+ run : |
79+ mkdir -p /tmp/digests
80+ digest="${{ steps.build.outputs.digest }}"
81+ touch "/tmp/digests/${digest#sha256:}"
82+
83+ - name : Upload digest
84+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
85+ with :
86+ name : digests-${{ matrix.image.name }}-${{ matrix.platform.arch }}
87+ path : /tmp/digests/*
88+ if-no-files-found : error
89+ retention-days : 1
90+
91+ merge :
92+ name : Merge manifest (${{ matrix.image }})
93+ runs-on : ubuntu-24.04
94+ needs : build
95+ strategy :
96+ fail-fast : false
97+ matrix :
98+ image :
99+ - packages-builder-debian
100+ - packages-builder-alpine
101+ - packages-builder-rhel-8
102+ - packages-builder-rhel-9
103+ - packages-builder-rhel-10
104+ steps :
105+ - name : Download digests
106+ uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
107+ with :
108+ pattern : digests-${{ matrix.image }}-*
109+ path : /tmp/digests
110+ merge-multiple : true
111+
112+ - name : Set up Docker Buildx
113+ uses : docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
114+
115+ - name : Log in to GHCR
116+ uses : docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
117+ with :
118+ registry : ${{ env.REGISTRY }}
119+ username : ${{ github.actor }}
120+ password : ${{ secrets.GITHUB_TOKEN }}
121+
122+ - name : Create manifest list
123+ working-directory : /tmp/digests
124+ run : |
125+ docker buildx imagetools create \
126+ -t ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ matrix.image }}:latest \
127+ -t ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ matrix.image }}:${{ github.sha }} \
128+ $(printf '${{ env.REGISTRY }}/${{ env.OWNER }}/${{ matrix.image }}@sha256:%s ' *)
129+
130+ - name : Inspect manifest
131+ run : |
132+ docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ matrix.image }}:${{ github.sha }}
0 commit comments