mirror of
https://github.com/rommapp/romm.git
synced 2026-12-02 10:08:40 +01:00
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) <noreply@anthropic.com>
This commit is contained in:
41
.github/workflows/build.yml
vendored
41
.github/workflows/build.yml
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user