@@ -39,6 +39,10 @@ inputs:
3939 docker-build-target :
4040 description : " Sets the target stage to build"
4141 required : false
42+ docker-build-platforms :
43+ description : " Sets the target platforms for build"
44+ required : false
45+ default : ' linux/amd64'
4246 docker-build-provenance :
4347 description : " Generate provenance attestation for the build"
4448 required : false
@@ -151,6 +155,34 @@ runs:
151155 echo "tag=$TAG" >> $GITHUB_OUTPUT
152156 echo "tag_list=$TAG_LIST" >> $GITHUB_OUTPUT
153157
158+ - name : Verify Architecture Match
159+ shell : bash
160+ if : steps.preparation.outputs.build == 'true'
161+ run : |
162+ RUNNER_ARCH="${{ runner.arch }}" # X64 (AMD64) or ARM64
163+ TARGET_PLATFORMS="${{ inputs.docker-build-platforms }}"
164+
165+ echo "Runner CPU Architecture: $RUNNER_ARCH"
166+ echo "Requested Build Platforms: $TARGET_PLATFORMS"
167+
168+ # Check for AMD64 mismatch (Runner is X64, but user requests ONLY arm64, OR user requests multi-arch which requires emulation)
169+ if [[ "$RUNNER_ARCH" == "X64" ]]; then
170+ if [[ "$TARGET_PLATFORMS" == *"linux/arm64"* ]]; then
171+ echo "::error::Runner is X64 (Intel/AMD) but build includes 'linux/arm64'. This requires emulation. Aborting strictly."
172+ exit 1
173+ fi
174+ fi
175+
176+ # Check for ARM64 mismatch
177+ if [[ "$RUNNER_ARCH" == "ARM64" ]]; then
178+ if [[ "$TARGET_PLATFORMS" == *"linux/amd64"* ]]; then
179+ echo "::error::Runner is ARM64 (Apple Silicon/Graviton) but build includes 'linux/amd64'. This requires emulation. Aborting strictly."
180+ exit 1
181+ fi
182+ fi
183+
184+ echo "Architecture match verified for native build ✅"
185+
154186 - name : Set up Docker Buildx
155187 if : inputs.docker-username != '' && inputs.docker-password != ''
156188 uses : docker/setup-buildx-action@v3
@@ -177,7 +209,7 @@ runs:
177209 tags : ${{ steps.preparation.outputs.tag_list }}
178210 secrets : ${{ inputs.docker-build-secrets }}
179211 secret-files : ${{ inputs.docker-build-secret-files }}
180- platforms : linux/amd64
212+ platforms : ${{ inputs.docker-build-platforms }}
181213 cache-from : type=gha
182214 cache-to : type=gha,mode=max
183215 provenance : ${{ inputs.docker-build-provenance }}
0 commit comments