Skip to content

ci: sign and tag only the scanned image digest - #432

Merged
uniqueg merged 6 commits into
devfrom
ci/sign-scanned-digest
Oct 23, 2026
Merged

uniqueg merged 6 commits into
devfrom
ci/sign-scanned-digest

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #428 (base dev is not the default branch, so the issue is closed by hand after the merge).

The release and dev image flows now sign and tag exactly the image that was scanned:

  1. push (Push image (Python X)): builds each image once and pushes it by digest, untagged (with SBOM and provenance attestations); the release workflow also checks the FOCA version the image reports. The digest is passed on as an artifact (digest-pyV), as all jobs of a matrix share one set of outputs.
  2. scan (Scan image (Python X), unchanged name): scans <image>@<digest> with the shared scan-image action, in a job without Docker Hub credentials, signing identity or id-token. Pull requests still scan a local build.
  3. docker (Publish image (Python X)): only if the scan passed, attests and signs that digest, then tags it with docker buildx imagetools create and checks that each tag resolves to the signed digest. In the release workflow it still runs after the PyPI upload, which still waits for the scan.

A digest that fails the scan stays untagged and unsigned, and nothing refers to it.

The Docker Hub organization now comes from the repository variable DOCKERHUB_ORG (by default elixircloud), as scan.yml already did, through a workflow-level IMAGE_NAME. The secret-less scan job needs the image name too, and a name built from a secret would be masked in job outputs. The DOCKERHUB_ORG secret is no longer used.

Docs ("Verifying images and charts" in the deployment guide, "Image scan" in the contributing guide, the release steps in "Versioning and releases" of the contributing guide, moved there from the README by #429) now say that the published images are the scanned ones. The required checks (Unit tests, Scan images, ...) keep their names.

Mirrored in elixir-cloud-aai/cloud-registry#188 (same job structure and comments; Cloud Registry has a single image, so it passes the digest as a job output instead of an artifact).

How it was verified

  • actionlint (v1.7.12, with shellcheck 0.10.0): no findings on the changed workflows (only the existing SC2102 info on the lint job's pip install -e .[dev,docs]).
  • pre-commit run --all-files: all hooks pass.
  • Trivy v0.75.0 locally against an existing dev image by its index digest (docker.io/elixircloud/foca@sha256:5c3056..., remote source): the image index with attestation manifests resolves and scans correctly, as the new scan job does.
  • CI on this PR (pull request path: local build + scan for every Python version): all checks pass; Push image and Publish image are skipped, as they should be for pull requests. The same flow in cloud-registry (build: make project PEP 561 compliant #192, merged) ran the push path on dev successfully: dev and sha-<commit> point to the scanned and signed digest. The push path (push -> scan by digest -> docker) runs only on pushes to dev, so it first runs after the merge; I will watch that run. The release path runs only for a tag and could not be run before a release.

Changes from the pre-push review: the local PR build is now tagged <image>:scan, so that code scanning matches the OS package findings of PRs and pushes (Trivy derives their location from the repository name; after the merge, the dev OS package alerts are recreated once under the new location). The scan now runs only for PRs or after a successful push. The comments say that digests of failed runs stay on Docker Hub, untagged.

Declined review findings

  • Extract the digest-read and tag-and-verify snippets into composite actions or scripts: each is a few lines of inline shell, which matches the style of the other jobs. A shared action would add indirection without making anything safer.
  • Make push wait for lint and tests: it runs alongside them on purpose, so that the scan starts early. Untagged digests of failed runs are harmless, and this is documented.
  • Fall back to a local build when the Docker Hub secrets are missing (forks): pushes to dev publish images, and that already needed the secrets before this change.

Notes for maintainers

  • The DOCKERHUB_ORG secret is no longer read. Forks that publish elsewhere set the repository variable DOCKERHUB_ORG instead (for elixircloud nothing needs to be set).
  • Untagged digests of failed runs accumulate on Docker Hub (pullable by digest only). A retention policy may be worth setting up.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Publish only Docker image digests that have passed vulnerability scanning, then attest, sign, and verify every resulting tag.

New Features:

  • Ensure development and release workflows scan the exact image digest that is ultimately published.

Bug Fixes:

  • Prevent images from being signed or tagged when their vulnerability scan fails or when tags resolve to a different digest.

Enhancements:

  • Separate image pushing, scanning, and publishing into distinct workflow stages with digest handoff and isolated scan permissions.
  • Use the repository DOCKERHUB_ORG variable for image naming and validate release image versions before scanning.
  • Align contributor and deployment documentation with the scanned-image publishing flow.

CI:

  • Update development and release CI workflows to push images by digest, scan them without registry credentials, then attest, sign, tag, and verify the published digest.

Documentation:

  • Document that published development and release images are the scanned images and that Docker Hub organization configuration uses DOCKERHUB_ORG.

uniqueg and others added 4 commits October 23, 2026 05:14
The release and dev image flows now build and push each image once, by
digest and untagged (job `push`), scan exactly that digest in a job
without credentials, signing identity or `id-token` (job `scan`, shared
`scan-image` action), and only if the scan passes attest, sign and tag
it, checking that each tag resolves to the signed digest (job
`docker`). Before, the published images were built a second time after
the scan. The digests are passed between the matrix jobs as artifacts.

The Docker Hub organization now comes from the repository variable
`DOCKERHUB_ORG` (by default `elixircloud`), as in `scan.yml`, so that
the secret-less scan job knows the image name; the `DOCKERHUB_ORG`
secret is no longer used.

Refs #428

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Describe the scan-before-sign flow in "Verifying images and charts",
the contributing guide's image scan section and the README's release
steps, and that all workflows take the Docker Hub organization from
the repository variable `DOCKERHUB_ORG`.

Refs #428

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Name the local pull request build like the pushed images, so that
  code scanning matches the OS package findings of pull requests and
  pushes (Trivy derives their location from the repository name).
- Run the scan only for pull requests or after a successful push.
- Say that digests of failed runs stay on Docker Hub, untagged.
- Docs: limit the claim to images published from now on, state what
  passing the scan means, and re-wrap the edited paragraphs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The workflows now build and push each image once by immutable digest, scan that exact digest in an isolated job, and only then attest, sign, and tag it with verification; image naming now uses the DOCKERHUB_ORG repository variable, and the documentation reflects the new publication and release flow.

Sequence diagram for digest-based image publication

sequenceDiagram
    participant Push as Push image
    participant Registry as Docker Hub
    participant Scan as Scan image
    participant Docker as Publish image

    Push->>Registry: Build and push image by digest
    Push->>Scan: Upload digest-pyV artifact
    Scan->>Scan: Download image digest
    Scan->>Registry: Scan IMAGE_NAME@digest
    Scan-->>Docker: Scan passed
    Docker->>Registry: Attest build provenance
    Docker->>Registry: cosign sign IMAGE_NAME@digest
    Docker->>Registry: docker buildx imagetools create
    Docker->>Registry: docker buildx imagetools inspect
Loading

Flow diagram for scanned image publication

flowchart TD
    A[Build image once] --> B[Push untagged image by digest]
    B --> C[Scan exact digest]
    C -->|scan passes| D[Attest and sign digest]
    D --> E[Tag digest]
    E --> F[Verify tag resolves to digest]
    C -->|scan fails| G[Remain untagged and unsigned]
Loading

File-Level Changes

Change Details Files
Separate image publication into push, scan, and publish stages so only the exact scanned digest is attested, signed, and tagged.
  • Build each matrix image once and push it untagged by digest with SBOM and provenance attestations.
  • Transfer and validate digests through artifacts between jobs.
  • Scan pushed digests without Docker Hub credentials or signing permissions; retain local builds for pull requests.
  • Attest, sign, tag, and verify tag resolution only after scans pass.
.github/workflows/checks.yml
.github/workflows/release.yml
Standardize Docker Hub image resolution through a workflow-level repository-variable-based image name.
  • Use DOCKERHUB_ORG with an elixircloud default instead of the deprecated secret.
  • Use the same fully qualified image name for anonymous scanning, attestations, signatures, and tags.
.github/workflows/checks.yml
.github/workflows/release.yml
Update CI and release documentation to describe scanned-image publication and the revised configuration.
  • Document that release and dev tags reference the scanned digest.
  • Move and update release and image-scan guidance, including repository-variable configuration and untagged failed digests.
docs/contributing.md
docs/deployment.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Resolve the conflicts with #429, which moved the release steps from
the README to "Versioning and releases" in the contributing guide:
describe the scan-before-sign flow there, and point the release
workflow's header to it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (004fe8e) to head (86afc53).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #432   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         2869      2869           
=========================================
  Hits          2869      2869           
Flag Coverage Δ
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review October 23, 2026 12:13

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the digest handoff or scan gate is wrong, an image that was not actually scanned could still be signed and published under the expected tags, and downstream users may already have pulled or deployed it. Reverting can remove or correct the tags, but it cannot undo those uses.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@uniqueg
uniqueg merged commit 6d2989c into dev Oct 23, 2026
23 checks passed
@uniqueg
uniqueg deleted the ci/sign-scanned-digest branch October 23, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant