From 69c72ffe2a62a8bce9ae43ee6a0d4dfec4c2fe9e Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Mon, 28 Sep 2026 14:50:20 -0400 Subject: [PATCH] ci: move image signing into its own job (code-review) A Sigstore or registry failure while signing no longer skips the scan of an already published image. Grants artifact-metadata: write so the attestation storage records are created. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/build.yml | 41 +++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ada1decbf..7b8cb1f2a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -211,12 +211,11 @@ jobs: permissions: contents: read packages: write - # Keyless cosign signing and GitHub provenance attestations. - id-token: write - attestations: write outputs: version: ${{ steps.meta.outputs.version }} version-slim: ${{ steps.meta-slim.outputs.version }} + digest-slim: ${{ steps.push.outputs.digest-slim }} + digest-full: ${{ steps.push.outputs.digest-full }} steps: - name: Download slim digests uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 @@ -311,14 +310,40 @@ jobs: push_variant /tmp/digests/slim "$SLIM_METADATA" digest-slim push_variant /tmp/digests/full "$FULL_METADATA" digest-full + # Its own job so a signing failure can't skip `scan` of an already published image. + sign: + needs: merge + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: read + packages: write + # Keyless cosign signing, provenance attestations and their storage records. + id-token: write + attestations: write + artifact-metadata: write + steps: + - name: Login to Docker Hub + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Install cosign uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 # Both registries, since a signature is stored next to the image it covers. - name: Sign images env: - SLIM_DIGEST: ${{ steps.push.outputs.digest-slim }} - FULL_DIGEST: ${{ steps.push.outputs.digest-full }} + SLIM_DIGEST: ${{ needs.merge.outputs.digest-slim }} + FULL_DIGEST: ${{ needs.merge.outputs.digest-full }} run: | while IFS= read -r image; do [[ -n "$image" ]] || continue @@ -330,14 +355,14 @@ jobs: uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 with: subject-name: ${{ env.DIGEST_IMAGE }} - subject-digest: ${{ steps.push.outputs.digest-slim }} + subject-digest: ${{ needs.merge.outputs.digest-slim }} push-to-registry: true - name: Attest full image provenance uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 with: subject-name: ${{ env.DIGEST_IMAGE }} - subject-digest: ${{ steps.push.outputs.digest-full }} + subject-digest: ${{ needs.merge.outputs.digest-full }} push-to-registry: true # Records what shipped; image-scan.yml's weekly run rescans latest. @@ -354,7 +379,7 @@ jobs: "ghcr.io/${{ github.repository_owner }}/romm:${{ needs.merge.outputs.version-slim }}"] report-failure: - needs: [validate-tag-semver, build, merge, scan] + needs: [validate-tag-semver, build, merge, sign, scan] if: failure() && github.event_name == 'schedule' permissions: contents: read