Generates CycloneDX SBOMs for what a deploy job shipped, using Syft, and uploads them to VizzHub, which keeps the software inventory of every live project.
It can take the deployed images one by one, as a list, from a compose file or from rendered Kubernetes manifests; add the dependencies declared in the source (lockfiles); and record the runtime platform (Beanstalk platform version, Kubernetes version, anything you declare).
The action never fails the calling job. If Syft cannot be installed, an image cannot be resolved or scanned, or an upload is rejected, it emits a workflow warning and the deploy carries on.
Add the step at the end of the job that deploys to a GitHub environment named production,
production-<suffix>, staging or staging-<suffix>, after the images are pushed and the job is
logged in to their registry:
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write # the upload authenticates with the job's GitHub OIDC token
contents: read
steps:
# ... build, push and deploy ...
- uses: Vizzuality/sbom@<full commit sha> # vX.Y.Z
with:
image: ghcr.io/vizzuality/my-app:${{ github.sha }}
component: apiReference the action by full commit SHA, never by a branch or tag.
The job's environment: is what VizzHub records: it is read from the OIDC token, never from an
input. The action checks it first: when the job has no environment, or one that is not
production, staging, production-<x> or staging-<x> (case-insensitive), it stops with a
notice before scanning anything. So the step can sit in a deploy job that also deploys dev or
previews: no if: needed, and those runs cost nothing.
Declare permissions: with both id-token: write and contents: read: a job-level
permissions: block replaces the defaults, so id-token: write alone breaks actions/checkout.
Adding environment: to a job that did not have one changes more than the SBOM upload:
- The OIDC
subclaim changes for every token the job mints, fromrepo:<org>/<repo>:ref:refs/heads/main(or...:ref:refs/tags/v1.2.3) torepo:<org>/<repo>:environment:production. Any cloud role the job already assumes through OIDC (AWSconfigure-aws-credentials, GCP, Azure...) whose trust policy matches onrefstops working, and the deploy itself fails. Check every OIDC role used in that job before addingenvironment:, and add theenvironment:subjects to their trust policies first. - A new role for the SBOM step (ECR pull, ECS or Beanstalk describe) must trust
repo:<org>/<repo>:environment:production, andrepo:<org>/<repo>:environment:stagingif staging also uploads. - Required reviewers on the environment pause the whole deploy job until someone approves it, not only the SBOM step. Branch and tag rules do not pause anything.
- Container jobs (
container:on the job) need the Docker CLI with buildx,jqandyqin the container; without them every image is skipped with a warning.
At least one of image, images, compose-file, manifests, source-path or a platform input
is needed. They combine: one run can scan a compose file and a list of extra images.
| Input | Default | Notes |
|---|---|---|
image |
One deployed image, by tag or digest. Needs component. |
|
component |
Component name for image: lowercase letters, digits and -, up to 64 (api, client, worker...). |
|
images |
One component=ref per line. Blank lines and # comments are ignored. |
|
compose-file |
Compose file. Every service with an image: is scanned under the service name; services with only build: are skipped with a warning. The file is read with docker compose config, so ${VAR} is interpolated from the job's environment. |
|
compose-profiles |
Profiles to enable, comma or space separated. | |
manifests |
Rendered Kubernetes YAML (e.g. helm template output). Containers and initContainers of Deployments, StatefulSets, DaemonSets, Jobs and CronJobs are scanned under the container name. |
|
image-platform |
runner's | Platform the servers run, e.g. linux/arm64. See Multi-arch images. |
source-path |
Directory scanned for lockfiles (syft scan dir:). See Source. |
|
source-component |
Component the source is merged into. See Source. | |
platform |
One name=version per line, e.g. nginx=1.24. See Platform. |
|
beanstalk-environment |
Elastic Beanstalk environment name. Needs AWS credentials in the job. | |
kubernetes |
false |
true records the cluster version from kubectl version. Needs a configured kubectl. |
environment |
production |
Label for the platform document only (platform:<environment>). Set it to the job's environment: in a staging job, leave it out and the platform document is labelled platform:production. |
vizzhub-url |
https://hub.vizzuality.com |
|
upload |
true |
false only generates the SBOMs (used by this repo's tests). |
Component names that come from compose services or container names are made valid: lowercased,
anything outside a-z0-9- replaced by -, cut to 64 characters. When two different images end up
with the same name, the second becomes <name>-2, the third <name>-3. The same image under the
same name twice (an initContainer reused across workloads) is one component. The same image under
two names is scanned once and uploaded once per name. Names you give explicitly (component,
images) are never changed: an invalid one is skipped with a warning.
| Output | |
|---|---|
uploaded |
Number of SBOMs uploaded. |
skipped |
Number of components or documents that did not reach VizzHub (unresolvable image, failed scan, build-only service, rejected upload...). Each has a warning. |
results |
Path to a JSON array with one entry per generated SBOM: kind (image, source, platform), component, image, digest, file, components. |
sbom-file, digest, components |
The first image's SBOM path, scanned manifest digest and component count. |
- Downloads the pinned Syft release for the runner (
linux_amd64on GitHub-hosted runners) and verifies it against the SHA-256 pinned inaction.yml; on a mismatch nothing is scanned. The Syft version cannot be overridden: upgrading it is a new release of this action, with new pins. Syft is not downloaded when the run only records the platform. - Collects the images from every input and resolves each reference to its manifest digest with
docker buildx imagetools inspect(for a multi-arch image, the manifest of one platform: see below). Then it scans<image name>@<digest>straight from the registry withsyft scan registry:..., so each SBOM describes exactly the bytes that were deployed. Only packages are recorded (SYFT_FILE_METADATA_SELECTION=none): per-file entries would multiply the size by about 4. - Adds the source and platform documents, if asked.
- For each SBOM, requests a GitHub OIDC token with audience
vizzhuband sends the gzipped document toPOST /api/sbom/ingestwith the headersX-Sbom-Image,X-Sbom-Digest,X-Sbom-ComponentandX-Sbom-Expected-Components. One upload per component and digest.
X-Sbom-Expected-Components lists every component the run meant to upload, including the ones
whose scan failed. VizzHub uses it to flag a deploy where some images reached it and others did
not: that deploy stays missing in the coverage check, with the failed components named.
VizzHub trusts only the verified token for the repository, commit, ref, environment and run. Uploads are accepted from repositories owned by Vizzuality that belong to a live project, and only from production and staging environments.
For a multi-arch image (an index), the action picks the manifest of one platform, scans it and
records that manifest's digest, so the SBOM always matches one concrete image. The platform is
image-platform, or the runner's when it is empty (linux/amd64 on ubuntu-latest). Set it when
the servers run another one, for example linux/arm64 on Graviton. If the index has no image for
that platform the component is skipped with a warning rather than scanned for the wrong one. The
SBOM metadata keeps the platform (vizzhub:platform) and the index digest
(vizzhub:index-digest).
- Deployed by tag. A notice for every image whose reference is a tag other than a commit SHA
(
redis:7-alpine,my-app:production): the tag can move between the deploy and the scan. - Secrets baked into the image. A warning listing the names of
ENVvariables that look like secrets (*PASSWORD*,*SECRET*,*TOKEN*,*_KEY,DATABASE_URL...), ignoring public build-time prefixes (NEXT_PUBLIC_,VITE_...). Only names are read, never values. Anyone who can pull the image can read them: pass them at runtime instead. Syft itself does not copyENVvalues into the SBOM.
The action resolves tags when it runs, after the deploy. For your own images tagged with the commit
SHA in a registry with immutable tags that is the same image. For a third-party tag such as
redis:7-alpine it is not: the tag may move between the server's pull and the scan. Deploy those by
digest (redis:7-alpine@sha256:...) and pass the same reference to the action.
source-path scans a directory for lockfiles (package-lock.json, pnpm-lock.yaml, uv.lock,
poetry.lock...). Point it at the app's directory, not the repository root, or it also picks up
other apps' lockfiles.
- With
source-componentempty, the source is merged into every image SBOM of the run. - With
source-componentset, it is merged only into that component. - It complements image SBOMs; use it together with
images,compose-fileormanifests.
Merged components carry the property vizzhub:origin=source. A source package already in the image
(same purl, or same lowercase name@version when it has no purl) is not added twice.
When platform, beanstalk-environment or kubernetes is set, the action uploads one more
document, component platform, image platform:<environment>, whose components have the CycloneDX
type platform:
- each
name=versionline ofplatform; aws-elastic-beanstalk-platform, with the version from the environment'sPlatformArn(e.g.4.3.1) and the solution stack name as description (aws elasticbeanstalk describe-environments);kubernetes, with the servergitVersion(kubectl version -o json).
The <environment> in the label comes from the environment input, not from the token (the token
is not readable before it is minted). Set environment: staging in staging jobs, or the label says
production even though VizzHub files the document under staging.
The document has no timestamp or serial number and its digest is the SHA-256 of its bytes: the same platform gives the same digest. Platform data from this document is separate from the platform services a manager declares by hand in VizzHub; both are shown.
All snippets go in a job with environment: set and permissions: id-token: write. Replace
<full commit sha> with the pinned commit of this action. If the job has no environment: yet,
read Before adding environment: to a job first: it changes
the OIDC subject of every role the job assumes.
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write
contents: read
packages: read
steps:
# ... build, push to GHCR, deploy ...
- uses: Vizzuality/sbom@<full commit sha> # vX.Y.Z
with:
images: |
api=ghcr.io/vizzuality/my-app-api:${{ github.sha }}
client=ghcr.io/vizzuality/my-app-client:${{ github.sha }}The environment is computed from the release, and the same value labels the platform document:
on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.event.release.prerelease && 'staging' || 'production' }}
permissions:
id-token: write
contents: read
steps:
# ... deploy the tagged commit ...
- uses: Vizzuality/sbom@<full commit sha> # vX.Y.Z
with:
images: |
api=ghcr.io/vizzuality/my-app-api:${{ github.sha }}
platform: |
nginx=1.27
environment: ${{ github.event.release.prerelease && 'staging' || 'production' }}For servers deployed with a compose file. Image tags must be resolvable in the job, so pass the same variables the deploy uses:
- uses: Vizzuality/sbom@<full commit sha> # vX.Y.Z
env:
TAG: ${{ github.sha }} # used as ${TAG} in docker-compose.prod.yml
with:
compose-file: docker-compose.prod.yml
compose-profiles: productionServices built on the server (build: without image:) cannot be scanned from a registry and are
skipped with a warning. Push them to a registry and reference them by image: to cover them.
Render the chart with the values used for the deploy and scan the result:
- name: Render the release
run: |
helm template my-app ./chart -f values.production.yaml \
--set image.tag="${GITHUB_SHA}" > "${RUNNER_TEMP}/rendered.yaml"
- uses: Vizzuality/sbom@<full commit sha> # vX.Y.Z
with:
manifests: ${{ runner.temp }}/rendered.yaml
kubernetes: true # needs the kubectl context the deploy usedFlightcontrol builds the images itself and pushes them to ECR in the project's AWS account, then runs them on ECS. The SBOM step therefore runs after the deploy has finished, logs in to that ECR and scans what ECS is actually running. The release job's existing "wait for it to finish" step stays as it is.
A release job that triggers a deploy hook often has no environment:; this recipe adds one. See
Before adding environment: to a job: the role below must
trust repo:<org>/<repo>:environment:production and ...:environment:staging (not ref), any
other OIDC role in the job must be checked first, and required reviewers would pause the release
job before it calls the hook.
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.event.release.prerelease && 'staging' || 'production' }}
permissions:
id-token: write
contents: read
steps:
# ... trigger the deploy hook with commit=<tagged commit> ...
# ... wait until the deployment is SUCCESS or NO_CHANGE ...
- uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6
continue-on-error: true
with:
role-to-assume: ${{ vars.SBOM_AWS_ROLE_ARN }} # read-only: ECS describe + ECR pull
aws-region: ${{ vars.AWS_REGION }}
- uses: aws-actions/amazon-ecr-login@4282e2b4f4018fbb1d76a177de8ce052de19b55e # v2
continue-on-error: true
# Reads the image each ECS service is running, so a NO_CHANGE deploy still reports the
# images that are live.
- name: Deployed images
id: refs
continue-on-error: true
env:
CLUSTER: ${{ vars.FC_ECS_CLUSTER }}
SERVICES: ${{ vars.FC_ECS_SERVICES }} # "api=<ecs service> tiler=<ecs service>"
run: |
set -euo pipefail
images=""
for pair in $SERVICES; do
td=$(aws ecs describe-services --cluster "$CLUSTER" --services "${pair#*=}" \
--query 'services[0].taskDefinition' --output text)
image=$(aws ecs describe-task-definition --task-definition "$td" \
--query 'taskDefinition.containerDefinitions[0].image' --output text)
images+="${pair%%=*}=${image}"$'\n'
done
# Written once, at the end: a failing aws call above leaves no half-written output.
printf 'images<<EOF\n%sEOF\n' "$images" >> "$GITHUB_OUTPUT"
- uses: Vizzuality/sbom@<full commit sha> # vX.Y.Z
with:
images: ${{ steps.refs.outputs.images }}
environment: ${{ github.event.release.prerelease && 'staging' || 'production' }}To confirm per project before enabling (not visible from the repository: Flightcontrol keeps its
configuration in its dashboard unless the repo has a flightcontrol.json):
- the ECS cluster and service names Flightcontrol created for each environment, which go in the
FC_ECS_CLUSTERandFC_ECS_SERVICESvariables of each GitHub environment; - that the task definition's first container is the app (Flightcontrol may add sidecars);
- an IAM role trusted by the repository's OIDC subject with
ecs:DescribeServices,ecs:DescribeTaskDefinitionand ECR pull on those repositories.
If the ECR repository naming and the image tag (commonly the commit SHA) are confirmed instead, the
"Deployed images" step can be replaced by fixed images: lines, but they then describe the commit
that was requested, not what ECS is running.
- uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6
continue-on-error: true
with:
role-to-assume: ${{ vars.DEPLOY_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION }}
- uses: Vizzuality/sbom@<full commit sha> # vX.Y.Z
with:
images: |
api=${{ vars.ECR_REGISTRY }}/my-app-api:${{ github.sha }}
beanstalk-environment: my-app-production
platform: |
postgresql=16.4The role needs elasticbeanstalk:DescribeEnvironments.
For projects whose last deploy predates the action. Run it by hand once per environment, with the references currently running:
name: SBOM backfill
on:
workflow_dispatch:
inputs:
images:
description: One component=ref per line, the images running now
required: true
jobs:
sbom:
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write
contents: read
steps:
# ... registry login ...
- uses: Vizzuality/sbom@<full commit sha> # vX.Y.Z
with:
images: ${{ inputs.images }}Because the job names an environment, GitHub records it as one more deployment of the repository,
and VizzHub's Deployment Frequency counts it once. Its OIDC subject is
repo:<org>/<repo>:environment:production, so the registry-login role must trust that subject,
and required reviewers on production will hold the run until approved (see
Before adding environment: to a job). The token carries the commit the workflow ran
on, which may not be the commit that is deployed.
VizzHub accepts any OIDC token minted for a production* or staging* environment, and GitHub
creates an environment the first time a job names it. Without deployment rules, any branch could
upload an SBOM as production. In each repository's Settings → Environments:
production: for push deploys, deployment branches limited tomain; for release deploys, tags matchingv*.staging: the branches or tags that deploy staging (v*covers pre-releases too).
Tag convention: vX.Y.Z for releases, vX.Y.Z-rc.N for pre-releases. The v* pattern cannot tell
the two apart: what keeps a pre-release out of production is the workflow's prerelease switch
(github.event.release.prerelease && 'staging' || 'production'), not the tag rule.
Before turning these rules on, see
Before adding environment: to a job: the environment changes
the OIDC subject of every role the job assumes, and required reviewers pause the deploy job.
Ready to paste at the end of the deploy job in .github/workflows/deploy.yml (after
"Deploy containers", before "Deployment summary") once this repository has a commit to pin.
The deploy job has no registry login of its own, so the snippet adds one; the GitHub Actions
role already has ECR pull permissions.
# - name: Login to Amazon ECR (SBOM scan)
# uses: aws-actions/amazon-ecr-login@4282e2b4f4018fbb1d76a177de8ce052de19b55e # v2
# continue-on-error: true # an SBOM login failure must never fail the deploy
#
# - name: SBOM
# uses: Vizzuality/sbom@<full commit sha> # vX.Y.Z
# with:
# images: |
# api=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/hub/backend:${{ github.sha }}
# client=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/hub/frontend:${{ github.sha }}The logic lives in scripts/sbom.sh (steps collect, scan, platform, upload, summary,
sharing state in a temporary directory); action.yml installs Syft and passes every input through
env:. The script is Bash 3.2 compatible for macOS runners.
.github/workflows/test.yml runs the action with upload: false in three jobs: a single image
(alpine:3.20), an images list with a repeated image and a platform line, and a compose file with
a build-only service. Each asserts on the outputs.
Locally: actionlint, shellcheck scripts/sbom.sh, and the script itself with SBOM_WORK set to an
empty directory and the inputs as SBOM_* variables (see the env: blocks in action.yml).