@@ -107,15 +107,24 @@ jobs:
107107 id : build
108108 uses : docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
109109 with :
110- platforms : linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64, linux/386, linux/ppc64le, linux/riscv64, linux/s390x
110+ 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' }}
111111 context : " {{ defaultContext }}:stable/alpine-slim"
112112 labels : ${{ steps.meta.outputs.labels }}
113113 annotations : ${{ steps.meta.outputs.annotations }}
114114 tags : ${{ steps.meta.outputs.tags }}
115115 push : ${{ github.event_name != 'pull_request' }}
116+ outputs : ${{ github.event_name == 'pull_request' && 'type=docker,dest=/tmp/alpine-slim.tar' || '' }}
116117 # cache-from: type=gha,scope=stable-alpine-slim
117118 # cache-to: type=gha,mode=min,scope=stable-alpine-slim
118119
120+ - name : Upload Alpine slim image artifact
121+ if : ${{ github.event_name == 'pull_request' }}
122+ uses : actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
123+ with :
124+ name : alpine-slim-image
125+ path : /tmp/alpine-slim.tar
126+ retention-days : 1
127+
119128 - name : Sign Docker Hub Manifest
120129 if : ${{ github.event_name != 'pull_request' }}
121130 run : |
@@ -151,6 +160,28 @@ jobs:
151160 - name : Check out the codebase
152161 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
153162
163+ - name : Download Alpine slim image artifact
164+ if : ${{ github.event_name == 'pull_request' }}
165+ uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
166+ with :
167+ name : alpine-slim-image
168+ path : /tmp
169+
170+ - name : Load Alpine slim image
171+ if : ${{ github.event_name == 'pull_request' }}
172+ run : |
173+ docker load --input /tmp/alpine-slim.tar
174+ docker image ls -a
175+
176+ - name : Generate slim image tag for PR builds
177+ if : ${{ github.event_name == 'pull_request' }}
178+ id : slim-tag
179+ run : |
180+ # Get the tag that was loaded from the artifact
181+ SLIM_TAG=$(docker image ls --format "table {{.Repository}}:{{.Tag}}" | grep -v REPOSITORY | grep slim | head -1)
182+ echo "tag=${SLIM_TAG}" >> "$GITHUB_OUTPUT"
183+ echo "Using slim image: ${SLIM_TAG}"
184+
154185 - name : Set up QEMU
155186 uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
156187
0 commit comments