@@ -111,15 +111,24 @@ jobs:
111111 id : build
112112 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
113113 with :
114- platforms : linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64, linux/386, linux/ppc64le, linux/riscv64, linux/s390x
114+ platforms : ${{ github.event_name == 'pull_request' && ' linux/amd64' || 'linux/amd64 , linux/arm/v6, linux/arm/v7, linux/arm64, linux/386, linux/ppc64le, linux/riscv64, linux/s390x' }}
115115 context : " {{ defaultContext }}:mainline/alpine-slim"
116116 labels : ${{ steps.meta.outputs.labels }}
117117 annotations : ${{ steps.meta.outputs.annotations }}
118118 tags : ${{ steps.meta.outputs.tags }}
119119 push : ${{ github.event_name != 'pull_request' }}
120+ outputs : ${{ github.event_name == 'pull_request' && 'type=docker,dest=/tmp/alpine-slim.tar' || '' }}
120121 # cache-from: type=gha,scope=alpine-slim
121122 # cache-to: type=gha,mode=min,scope=alpine-slim
122123
124+ - name : Upload Alpine slim image artifact
125+ if : ${{ github.event_name == 'pull_request' }}
126+ uses : actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
127+ with :
128+ name : alpine-slim-image
129+ path : /tmp/alpine-slim.tar
130+ retention-days : 1
131+
123132 - name : Sign Docker Hub Manifest
124133 if : ${{ github.event_name != 'pull_request' }}
125134 run : |
@@ -159,6 +168,28 @@ jobs:
159168 - name : Check out the codebase
160169 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
161170
171+ - name : Download Alpine slim image artifact
172+ if : ${{ github.event_name == 'pull_request' }}
173+ uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
174+ with :
175+ name : alpine-slim-image
176+ path : /tmp
177+
178+ - name : Load Alpine slim image
179+ if : ${{ github.event_name == 'pull_request' }}
180+ run : |
181+ docker load --input /tmp/alpine-slim.tar
182+ docker image ls -a
183+
184+ - name : Generate slim image tag for PR builds
185+ if : ${{ github.event_name == 'pull_request' }}
186+ id : slim-tag
187+ run : |
188+ # Get the tag that was loaded from the artifact
189+ SLIM_TAG=$(docker image ls --format "table {{.Repository}}:{{.Tag}}" | grep -v REPOSITORY | grep slim | head -1)
190+ echo "tag=${SLIM_TAG}" >> "$GITHUB_OUTPUT"
191+ echo "Using slim image: ${SLIM_TAG}"
192+
162193 - name : Set up QEMU
163194 uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
164195
@@ -229,15 +260,25 @@ jobs:
229260 id : build
230261 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
231262 with :
232- platforms : linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64, linux/386, linux/ppc64le, linux/riscv64, linux/s390x
263+ platforms : ${{ github.event_name == 'pull_request' && ' linux/amd64' || 'linux/amd64 , linux/arm/v6, linux/arm/v7, linux/arm64, linux/386, linux/ppc64le, linux/riscv64, linux/s390x' }}
233264 context : " {{ defaultContext }}:mainline/alpine"
234265 labels : ${{ steps.meta.outputs.labels }}
235266 annotations : ${{ steps.meta.outputs.annotations }}
236267 tags : ${{ steps.meta.outputs.tags }}
268+ build-args : ${{ github.event_name == 'pull_request' && format('IMAGE={0}', steps.slim-tag.outputs.tag) || '' }}
237269 push : ${{ github.event_name != 'pull_request' }}
270+ outputs : ${{ github.event_name == 'pull_request' && 'type=docker,dest=/tmp/alpine.tar' || '' }}
238271 # cache-from: type=gha,scope=debian-perl
239272 # cache-to: type=gha,mode=min,scope=debian-perl
240273
274+ - name : Upload Alpine image artifact
275+ if : ${{ github.event_name == 'pull_request' }}
276+ uses : actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
277+ with :
278+ name : alpine-image
279+ path : /tmp/alpine.tar
280+ retention-days : 1
281+
241282 - name : Sign Docker Hub Manifest
242283 if : ${{ github.event_name != 'pull_request' }}
243284 run : |
@@ -277,6 +318,28 @@ jobs:
277318 - name : Check out the codebase
278319 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
279320
321+ - name : Download Alpine image artifact
322+ if : ${{ github.event_name == 'pull_request' }}
323+ uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
324+ with :
325+ name : alpine-image
326+ path : /tmp
327+
328+ - name : Load Alpine image
329+ if : ${{ github.event_name == 'pull_request' }}
330+ run : |
331+ docker load --input /tmp/alpine.tar
332+ docker image ls -a
333+
334+ - name : Generate alpine image tag for PR builds
335+ if : ${{ github.event_name == 'pull_request' }}
336+ id : alpine-tag
337+ run : |
338+ # Get the tag that was loaded from the artifact (should be alpine, not alpine-slim)
339+ ALPINE_TAG=$(docker image ls --format "table {{.Repository}}:{{.Tag}}" | grep -v REPOSITORY | grep -E "alpine$|alpine3" | head -1)
340+ echo "tag=${ALPINE_TAG}" >> "$GITHUB_OUTPUT"
341+ echo "Using alpine image: ${ALPINE_TAG}"
342+
280343 - name : Set up QEMU
281344 uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
282345
@@ -347,11 +410,12 @@ jobs:
347410 id : build
348411 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
349412 with :
350- platforms : linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64, linux/386, linux/ppc64le, linux/riscv64, linux/s390x
413+ platforms : ${{ github.event_name == 'pull_request' && ' linux/amd64' || 'linux/amd64 , linux/arm/v6, linux/arm/v7, linux/arm64, linux/386, linux/ppc64le, linux/riscv64, linux/s390x' }}
351414 context : " {{ defaultContext }}:mainline/alpine-perl"
352415 labels : ${{ steps.meta.outputs.labels }}
353416 annotations : ${{ steps.meta.outputs.annotations }}
354417 tags : ${{ steps.meta.outputs.tags }}
418+ build-args : ${{ github.event_name == 'pull_request' && format('IMAGE={0}', steps.alpine-tag.outputs.tag) || '' }}
355419 push : ${{ github.event_name != 'pull_request' }}
356420 # cache-from: type=gha,scope=alpine-perl
357421 # cache-to: type=gha,mode=min,scope=alpine-perl
@@ -395,6 +459,28 @@ jobs:
395459 - name : Check out the codebase
396460 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
397461
462+ - name : Download Alpine image artifact
463+ if : ${{ github.event_name == 'pull_request' }}
464+ uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
465+ with :
466+ name : alpine-image
467+ path : /tmp
468+
469+ - name : Load Alpine image
470+ if : ${{ github.event_name == 'pull_request' }}
471+ run : |
472+ docker load --input /tmp/alpine.tar
473+ docker image ls -a
474+
475+ - name : Generate alpine image tag for PR builds
476+ if : ${{ github.event_name == 'pull_request' }}
477+ id : alpine-tag
478+ run : |
479+ # Get the tag that was loaded from the artifact (should be alpine, not alpine-slim)
480+ ALPINE_TAG=$(docker image ls --format "table {{.Repository}}:{{.Tag}}" | grep -v REPOSITORY | grep -E "alpine$|alpine3" | head -1)
481+ echo "tag=${ALPINE_TAG}" >> "$GITHUB_OUTPUT"
482+ echo "Using alpine image: ${ALPINE_TAG}"
483+
398484 - name : Set up QEMU
399485 uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
400486
@@ -465,11 +551,12 @@ jobs:
465551 id : build
466552 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
467553 with :
468- platforms : linux/amd64, linux/arm64
554+ platforms : ${{ github.event_name == 'pull_request' && ' linux/amd64' || 'linux/amd64 , linux/arm64' }}
469555 context : " {{ defaultContext }}:mainline/alpine-otel"
470556 labels : ${{ steps.meta.outputs.labels }}
471557 annotations : ${{ steps.meta.outputs.annotations }}
472558 tags : ${{ steps.meta.outputs.tags }}
559+ build-args : ${{ github.event_name == 'pull_request' && format('IMAGE={0}', steps.alpine-tag.outputs.tag) || '' }}
473560 push : ${{ github.event_name != 'pull_request' }}
474561 # cache-from: type=gha,scope=alpine-otel
475562 # cache-to: type=gha,mode=min,scope=alpine-otel
0 commit comments