diff --git a/.github/workflows/python-docker.yml b/.github/workflows/python-docker.yml index 17528a3..79bd784 100644 --- a/.github/workflows/python-docker.yml +++ b/.github/workflows/python-docker.yml @@ -304,21 +304,46 @@ jobs: # Additional custom tags ${{ inputs.additional-tags }} + # #CRITICAL: external resources: the local-scan path below (push=false, + # enable-trivy-scan=true) needs this build to end up in the runner's + # local Docker image store, since "Export local image for scanning" + # does `docker save` on it. buildx only populates that store when + # `load: true` is set; without it, the image exists only in the build + # cache and docker save fails with "reference does not exist". Loading + # also requires a single-platform build (the docker exporter cannot + # materialize a multi-arch manifest list locally), so this path is + # pinned to linux/amd64 rather than the multi-arch default. The + # push=true path is untouched: it keeps full multi-platform builds and + # scans the pushed registry image instead (see the two Trivy steps + # below), so this only changes behavior on a path that previously + # failed on every single invocation. The Build Summary step below + # mirrors this same condition so it reports the platform actually + # built, not the raw input. + # #EDGE: security: the docker exporter (selected by load: true) does + # not support SBOM/provenance attestation output, so sbom/provenance + # are forced off below on this same path even when the caller's + # enable-sbom or enable-provenance inputs default to true; those + # attestations are only produced on the push=true path. + # #VERIFY: if a downstream caller ever needs local scanning of a + # non-amd64 image, replace the hardcoded linux/amd64 above with a + # dedicated platform input; confirm no current caller expects + # arm64-specific local-scan coverage before making that change. - name: Build and push Docker image id: build-push uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 with: context: ${{ inputs.context }} file: ${{ inputs.dockerfile }} - platforms: ${{ inputs.platforms }} + platforms: ${{ (inputs.enable-trivy-scan && steps.push-check.outputs.push != 'true') && 'linux/amd64' || inputs.platforms }} push: ${{ steps.push-check.outputs.push }} + load: ${{ inputs.enable-trivy-scan && steps.push-check.outputs.push != 'true' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: ${{ inputs.build-args }} cache-from: type=gha cache-to: type=gha,mode=max - sbom: ${{ inputs.enable-sbom }} - provenance: ${{ inputs.enable-provenance }} + sbom: ${{ (inputs.enable-trivy-scan && steps.push-check.outputs.push != 'true') && 'false' || inputs.enable-sbom }} + provenance: ${{ (inputs.enable-trivy-scan && steps.push-check.outputs.push != 'true') && 'false' || inputs.enable-provenance }} # Export local image for Trivy scanning when not pushed to registry - name: Export local image for scanning @@ -389,7 +414,7 @@ jobs: if: always() env: PUSH_STATUS: ${{ steps.push-check.outputs.push }} - PLATFORMS: ${{ inputs.platforms }} + PLATFORMS: ${{ (inputs.enable-trivy-scan && steps.push-check.outputs.push != 'true') && 'linux/amd64' || inputs.platforms }} IMAGE_TAGS: ${{ steps.meta.outputs.tags }} IMAGE_DIGEST: ${{ steps.build-push.outputs.digest }} IS_FORK: ${{ steps.check-fork.outputs.is_fork }}