@@ -41,19 +41,17 @@ jobs:
4141 uses : wyrihaximus/github-action-supported-php-versions@v1
4242 with :
4343 upcomingReleases : true
44- registry-matrix :
45- name : Extract registries from registry secret mapping
46- if : (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/master'
44+ supported-arch-matrix :
45+ name : Supported processor architectures
4746 runs-on : ubuntu-latest
48- needs :
49- - check-mark
5047 outputs :
51- registry : ${{ steps.registry- matrix.outputs.registry }}
48+ arch : ${{ steps.supported-arch- matrix.outputs.arch }}
5249 steps :
53- - id : registry-matrix
54- name : Extract registries from registry secret mapping
50+ - uses : actions/checkout@v1
51+ - id : supported-arch-matrix
52+ name : Generate Arch
5553 run : |
56- echo "::set-output name=registry::$(printenv DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING | jq -c 'keys') "
54+ echo "::set-output name=arch::[\"amd64\",\"arm64\",\"arm\"] "
5755 image-type-matrix :
5856 name : Create Image Type Matrix
5957 runs-on : ubuntu-latest
@@ -121,45 +119,52 @@ jobs:
121119 entrypoint : hadolint
122120 args : Dockerfile-${{ matrix.type }}
123121 build :
124- name : Building "${{ matrix.image }}"
122+ name : Building "${{ matrix.image }}" on ${{ matrix.arch }}
125123 needs :
126124 - lint
127125 - image-matrix
126+ - supported-arch-matrix
128127 runs-on : ubuntu-latest
129128 strategy :
130129 fail-fast : false
131130 matrix :
132131 image : ${{ fromJson(needs.image-matrix.outputs.image) }}
132+ arch : ${{ fromJson(needs.supported-arch-matrix.outputs.arch) }}
133133 steps :
134134 - uses : actions/checkout@v2
135+ - uses : dbhi/qus/action@main
135136 - run : mkdir ./docker-image/
136- - run : ./build-php.sh $(echo "${{ matrix.image }}" | tr '-' ' ')
137+ - run : ./build-php.sh $(echo "${{ matrix.image }}" | tr '-' ' ') ${{ matrix.arch }}
137138 - run : cat ./docker-image/image.tags | xargs -I % docker inspect --format='%={{.Id}}:{{index .Config.Env 7}}' %
138139 - run : docker save "${DOCKER_IMAGE}" | gzip -9 > ./docker-image/image.tar
139140 - run : docker images
140141 - name : Upload Images
141142 uses : actions/upload-artifact@v2
142143 with :
143- name : docker-image-${{ matrix.image }}
144+ name : docker-image-${{ matrix.image }}-${{ matrix.arch }}
144145 path : ./docker-image
145146 scan-vulnerability :
146- name : Scanning "${{ matrix.image }}" for vulnerabilities
147+ name : Scanning "${{ matrix.image }}" for vulnerabilities on ${{ matrix.arch }}
147148 needs :
148149 - build
149150 - image-matrix
151+ - supported-arch-matrix
150152 runs-on : ubuntu-latest
151153 strategy :
152154 fail-fast : false
153155 matrix :
154156 image : ${{ fromJson(needs.image-matrix.outputs.image) }}
157+ arch : ${{ fromJson(needs.supported-arch-matrix.outputs.arch) }}
155158 steps :
156159 - uses : actions/checkout@v2
157160 if : contains(matrix.image, 'alpine')
161+ - uses : dbhi/qus/action@main
162+ if : contains(matrix.image, 'alpine')
158163 - name : Download Images
159164 if : contains(matrix.image, 'alpine')
160165 uses : actions/download-artifact@v2
161166 with :
162- name : docker-image-${{ matrix.image }}
167+ name : docker-image-${{ matrix.image }}-${{ matrix.arch }}
163168 path : ./docker-image
164169 - run : docker load --input ./docker-image/image.tar
165170 if : contains(matrix.image, 'alpine')
@@ -168,25 +173,30 @@ jobs:
168173 - run : make ci-scan-vulnerability
169174 if : contains(matrix.image, 'alpine')
170175 test :
171- name : Testing "${{ matrix.image }}"
176+ name : Testing "${{ matrix.image }}" on ${{ matrix.arch }}
172177 needs :
173178 - build
174179 - image-matrix
180+ - supported-arch-matrix
175181 runs-on : ubuntu-latest
176182 strategy :
177183 fail-fast : false
178184 matrix :
179185 image : ${{ fromJson(needs.image-matrix.outputs.image) }}
186+ arch : ${{ fromJson(needs.supported-arch-matrix.outputs.arch) }}
180187 steps :
181188 - uses : actions/checkout@v2
189+ - uses : dbhi/qus/action@main
182190 - name : Download Images
183191 uses : actions/download-artifact@v2
184192 with :
185- name : docker-image-${{ matrix.image }}
193+ name : docker-image-${{ matrix.image }}-${{ matrix.arch }}
186194 path : ./docker-image
187195 - run : ls -lasth ./docker-image
188196 - run : docker load --input ./docker-image/image.tar
189197 - run : IMAGE_BASE_VERSION=$(php -r 'echo explode("-", "${{ matrix.image }}")[2];') make $(php -r 'echo "test-", explode("-", str_replace(["zts-zts", "cli-nts"], ["zts", "nts"], "${{ matrix.image }}"))[0];')
198+ env :
199+ IMAGE_ARCH : ${{ matrix.arch }}
190200 - run : rm -Rf ./docker-image/
191201 check-mark :
192202 name : ✔️
@@ -198,56 +208,75 @@ jobs:
198208 runs-on : ubuntu-latest
199209 steps :
200210 - run : echo "✔️"
201- # push:
202- # name: Pushing "${{ matrix.image }}" to ${{ matrix.registry }}
203- # if: (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/master'
204- # needs:
205- # - check-mark
206- # - registry-matrix
207- # - image-matrix
208- # runs-on: ubuntu-latest
209- # strategy:
210- # fail-fast: false
211- # matrix:
212- # image: ${{ fromJson(needs.image-matrix.outputs.image) }}
213- # registry: ${{ fromJson(needs.registry-matrix.outputs.registry) }}
214- # steps:
215- # - uses: actions/checkout@v2
216- # - name: Download Images
217- # uses: actions/download-artifact@v2
218- # with:
219- # name: docker-image-${{ matrix.image }}
220- # path: ./docker-image
221- # - run: docker load --input ./docker-image/image.tar
222- # - run: cat ./docker-image/image.tags | xargs -I % docker tag % ${{ matrix.registry }}/%
223- # - run: make ci-push
224- # env:
225- # DOCKER_USER: ${{ secrets.HUB_USERNAME }}
226- # DOCKER_PASSWORD: ${{ secrets[fromJson(env.DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING)[matrix.registry]] }}
227- # DOCKER_REGISTRY: ${{ matrix.registry }}
228- build-and-push-all-archs :
229- name : Building and Pushing "${{ matrix.image }}" to ${{ matrix.registry }} for all additional archs
211+ push :
212+ name : Pushing "${{ matrix.image }}" for ${{ matrix.arch }}
230213 if : (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/master'
231214 needs :
232215 - check-mark
233- - registry-matrix
234216 - image-matrix
217+ - supported-arch-matrix
235218 runs-on : ubuntu-latest
236219 strategy :
237220 fail-fast : false
238221 matrix :
239222 image : ${{ fromJson(needs.image-matrix.outputs.image) }}
240- registry : ${{ fromJson(needs.registry- matrix.outputs.registry ) }}
223+ arch : ${{ fromJson(needs.supported-arch- matrix.outputs.arch ) }}
241224 steps :
242225 - uses : actions/checkout@v2
243- - name : Set up Docker Buildx
244- uses : crazy-max/ghaction-docker-buildx@v3
226+ - uses : dbhi/qus/action@main
227+ - name : Download Images
228+ uses : actions/download-artifact@v2
245229 with :
246- buildx-version : latest
247- qemu-version : latest
248- - run : make ci-docker-login
230+ name : docker-image-${{ matrix.image }}-${{ matrix.arch }}
231+ path : ./docker-image
232+ - run : docker load --input ./docker-image/image.tar
233+ - name : Login to container registries
234+ run : |
235+ (jq -r 'to_entries | map("echo \"$" + .value + "\" | docker login " + .key + " --username \"${{ env.DOCKER_USER }}\" --password-stdin") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
249236 env :
250237 DOCKER_USER : ${{ secrets.HUB_USERNAME }}
251- DOCKER_PASSWORD : ${{ secrets[fromJson(env.DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING)[matrix.registry]] }}
252- DOCKER_REGISTRY : ${{ matrix.registry }}
253- - run : ./buildx-php.sh $(echo "${{ matrix.image }}" | tr '-' ' ') ${{ matrix.registry }}
238+ GHCR_TOKEN : ${{ secrets.GHCR_TOKEN }}
239+ HUB_PASSCODE : ${{ secrets.HUB_PASSCODE }}
240+ - name : Retag
241+ run : |
242+ (jq -r 'to_entries | map("cat ./docker-image/image.tags | xargs -I % docker tag % " + .key + "/%") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
243+ - name : Push tags
244+ run : |
245+ (jq -r 'to_entries | map("cat ./docker-image/image.tags | xargs -I % docker push " + .key + "/%") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
246+ push-manifest :
247+ name : Push ${{ matrix.image }} manifest
248+ if : (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/master'
249+ strategy :
250+ fail-fast : false
251+ matrix :
252+ image : ${{ fromJson(needs.image-matrix.outputs.image) }}
253+ needs :
254+ - push
255+ - image-matrix
256+ - supported-arch-matrix
257+ runs-on : ubuntu-latest
258+ steps :
259+ - uses : actions/checkout@v2
260+ - uses : dbhi/qus/action@main
261+ - name : Download Images
262+ uses : actions/download-artifact@v2
263+ with :
264+ name : docker-image-${{ matrix.image }}-amd64
265+ path : ./docker-image
266+ - name : Login to container registries
267+ run : |
268+ (jq -r 'to_entries | map("echo \"$" + .value + "\" | docker login " + .key + " --username \"${{ env.DOCKER_USER }}\" --password-stdin") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
269+ env :
270+ DOCKER_USER : ${{ secrets.HUB_USERNAME }}
271+ GHCR_TOKEN : ${{ secrets.GHCR_TOKEN }}
272+ HUB_PASSCODE : ${{ secrets.HUB_PASSCODE }}
273+ - name : Docker info
274+ run : docker info
275+ - name : Push manifest to registries
276+ run : |
277+ touch command.sh
278+ (jq -r 'to_entries | map("cat ./docker-image/image.tags | xargs -I % php utils/create-manifest-command.php " + .key + " %") | .[]' <<<"$DOCKER_IMAGE_REGISTRIES_SECRET_MAPPING") | sh
279+ chmod +x command.sh
280+ ./command.sh
281+ env :
282+ TARGET_ARCHS : ${{ needs.supported-arch-matrix.outputs.arch }}
0 commit comments