Skip to content

Workflow base image digest

github-actions[bot] edited this page Nov 7, 2026 · 1 revision

base-image-digest

What it does. On a schedule, checks each external base image your Dockerfile or Containerfile pins by digest (FROM image:tag@sha256:...) against what that tag points to today. When the tag has moved, it scans the pinned digest and the current digest with Trivy and fails if the pinned one has a fixable HIGH or CRITICAL finding that the current one does not.

Why it exists. A digest pin freezes the build. When the maintainers republish the tag with a fix, nothing tells you until a release scan fails at tag time (a downstream project's v0.2.1 failed that way). This surfaces it on an ordinary Monday instead. It is opt-in; nothing existing changes.

How the verdict is reached

For each pinned external image:

  1. Resolve the tag's current digest with docker buildx imagetools inspect. A failure to resolve fails the job.
  2. If it equals the pin, stop: there is nothing newer to move to.
  3. Otherwise scan both digests with the Trivy binary pinned by hash in verify-published, with the flags container-release uses: trivy-severity (CRITICAL,HIGH), trivy-ignore-unfixed (true) and trivyignores.
  4. Fail if the pinned report has a finding (advisory ID and package, with a fixed version) that the current report lacks.

A finding both digests share does not fail, since bumping would not help. A finding with no fix does not fail. A Trivy error fails the job; it is never read as "nothing found". The findings and the line to change are written to the job summary. exit-code: "0" reports without failing.

The Dockerfile is read by scripts/base_image_digest.py (inlined byte for byte; tests/test_base_image_digest.py holds the copy identical). It follows FROM --platform=... image:tag@sha256:... AS name, line continuations, comments, stages (skipped) and scratch, and resolves ARG defaults set before the first FROM. It fails on a FROM with no digest (unless allow-unpinned), a digest with no tag, a variable it cannot resolve, a reference with anything outside the image grammar, and a file with no pinned external image.

Scheduling it

The workflow is workflow_call only, so the schedule lives in your caller:

on:
  schedule:
    - cron: "23 5 * * 1"   # weekly; choose your own minute
  workflow_dispatch:

permissions:
  contents: read

jobs:
  base-image:
    uses: ChiefGyk3D/git-your-ship-together/.github/workflows/base-image-digest.yml@<sha> # vX.Y.Z
    permissions:
      contents: read
    with:
      dockerfile: Containerfile

A red scheduled run is what notifies the repository's watchers. The job holds no issues: write on purpose (a called workflow's grants are checked when the caller starts, so asking for one would break every caller that did not give it). A caller that wants a tracking issue adds a job with needs: base-image and if: failure() that opens or updates one.

Limits

Public registries only: no credential is passed. One platform (platform). A registry that is not Docker Hub or GHCR needs its hosts in extra-allowed-endpoints. The comparison is by advisory ID and package.

Inputs (14), read from base-image-digest.yml:

Input Type Default Meaning
dockerfile string Dockerfile Path of the Dockerfile or Containerfile, relative to the repository. Every external FROM in it must be pinned by digest and name a tag (see allow-unpinned); a file with no pinned external image fails the job.
allow-unpinned boolean false Skip a FROM that has no @sha256: digest instead of failing on it. At least one pinned image must still be found.
platform string linux/amd64 Platform whose image is scanned, for example linux/amd64.
trivy-severity string CRITICAL,HIGH Severities Trivy reports; the same input and default as trivy-severity in container-release.yml.
trivy-ignore-unfixed boolean true Skip advisories that have no fixed version yet; the same input and default as trivy-ignore-unfixed in container-release.yml. A finding without a fix is never a reason to bump, so turning this off does not change the verdict.
trivyignores string empty Path to the caller's .trivyignore file, relative to the repository, as in container-release.yml. Empty means none. Every entry needs a reason and a review date.
exit-code string 1 Exit code when a bump would fix a finding. "1" (the default) fails the job; "0" reports in the job summary only.
trivy-version string 0.76.1 Trivy release to download (aquasecurity/trivy), without the v; the same pin as verify-published.yml. Changing it means changing trivy-sha256.
trivy-sha256 string c7cbe3137fb8a48a17574bede3dd6beb16742d1e9772929940fc90082c39d9c0 sha256 of trivy_<trivy-version>_Linux-64bit.tar.gz. The download is refused when it does not match.
egress-policy string block harden-runner egress policy - audit logs outbound connections, block allows only allowed-endpoints. Jobs that hold no secret follow egress-policy-secretless instead (EX-0001).
egress-policy-secretless string block harden-runner egress policy for the jobs that hold no stored secret, no OIDC token and no write-scoped or publish-capable token (read-only contents, a SARIF upload at most), and whose output no privileged job consumes - exactly audit or block. Defaults to block since security exception EX-0001 (GitHub-hosted runners in westus2 broke harden-runner block) was closed on 2026-11-02 after harden-runner v2.22.3 passed on westus2; see docs/security/exceptions/. Every job still has the default read-only job token. Set audit to opt out if the defect recurs. Any other job follows egress-policy. Any other value fails the job.
allowed-endpoints string api.github.com:443 auth.docker.io:443 docker-images-prod.s3.dualstack.us-east-1.amazonaws.com:443 fulcio.sigstore.dev:443 ghcr.io:443 github.com:443 index.docker.io:443 mirror.gcr.io:443 pkg-containers.githubusercontent.com:443 production.cloudfront.docker.com:443 raw.githubusercontent.com:443 registry-1.docker.io:443 rekor.sigstore.dev:443 release-assets.githubusercontent.com:443 timestamp.sigstore.dev:443 tmaproduction.blob.core.windows.net:443 tuf-repo-cdn.sigstore.dev:443 harden-runner allow-list for block, space-separated host:port entries. The default covers the Trivy download and database, GitHub, Docker Hub and GHCR; wildcards are not supported.
extra-allowed-endpoints string empty Appended to allowed-endpoints, for the registry of a base image that is not on Docker Hub or GHCR (quay.io:443, cdn01.quay.io:443). Same format.
timeout-minutes number 20 Job timeout.

What it refuses to do

It never writes to the repository, never opens an issue, holds no secret and passes nothing it could not scan.

Clone this wiki locally