Skip to main content
Plans: Every plan. Who: an owner or admin creates the API token; anyone who can edit the repository’s workflows adds the step.
This workflow generates a CycloneDX JSON SBOM with anchore/sbom-action (Syft) whenever you publish a release, and sends it to Pharus. It is the same workflow as the GitHub Actions tab of Connect a pipeline on the SBOMs page.

Before you start

1

Create a token

In Pharus, go to Settings → API tokens and create a token for the product family. See create a token.
2

Store it as a secret

In GitHub, open the repository’s Settings → Secrets and variables → Actions and add a repository secret named PHARUS_TOKEN with the token as its value.

The workflow

Save this as .github/workflows/pharus-sbom.yml:
What it does:
  • Trigger: every published release, and by hand from the Actions tab (workflow_dispatch).
  • Generate: anchore/sbom-action, pinned to the commit of its v0.24.2 release, runs Syft on the checked-out repository and writes sbom.cdx.json.
  • Version: the release tag becomes the product version in Pharus. A run started by hand uses the branch or tag name.
  • Send: the step gzips the file and posts it to POST /api/v1/sboms. The X-Pharus-* headers fill in the Pipeline card on the SBOM’s page, with a link back to the run.
  • Retry, then report: curl tries again through a short outage at Pharus (a 5xx answer, a timeout or a refused connection) for about a minute. Pharus answers a file it already has as a duplicate, so a retry is safe. If the upload still fails, --fail-with-body fails the step and prints Pharus’ message in the log. set -o pipefail makes a failed upload fail the step although its output goes on to tee.
  • Release anyway: continue-on-error: true keeps a failed upload from failing the run; the step still shows as failed. Remove the line if a release must not pass without its SBOM in Pharus.
  • Warnings: jq prints each line of the answer’s warnings as a warning on the run: gaps in the SBOM quality and components past end of life upstream. The SBOM is stored either way.

Update the action

The workflow pins anchore/sbom-action to a full commit SHA, with the release in a comment. A tag such as v0 can be moved to other code at any time; a commit SHA can’t, so the workflow keeps running the code you chose. Each release of the action installs one Syft version: v0.24.2 installs Syft 1.51.1 and checks the download against that Syft release’s checksum file. To move to a newer release, pick one from sbom-action’s releases and look up the commit its tag points to:
Use the SHA on the line ending in ^{} if there is one; otherwise the tag points straight at the commit. Replace the SHA and the comment together. Dependabot version updates for GitHub Actions can open these pull requests for you and update the comment too.

Variations

Set format: spdx-json and output-file: sbom.spdx.json on anchore/sbom-action, and gzip sbom.spdx.json in the last step. Pharus reads SPDX JSON 2.2 and 2.3.
Add image: with the image reference to anchore/sbom-action, for example image: ghcr.io/acme/gateway-g3:4.2, to describe the image instead of the source tree.
sbomify-action saves the SBOM it uploads as sbom_output.json. Add the Send SBOM to Pharus step after it, with gzip -c sbom_output.json and X-Pharus-Source: sbomify. The sbomify tab of Connect a pipeline has the step ready to copy.

Check that it worked

A successful run logs Pharus’ answer, for example:
The run’s summary shows the warnings, titled Pharus. In Pharus, the SBOM appears under SBOMs with GitHub Actions as its Source, and the token’s Last used time changes under Settings → API tokens. A re-run for the same release answers with "duplicate":true. If the step fails, the log shows the error code. The most common: All codes are listed under errors.

Upload an SBOM

API introduction

Azure Pipelines

GitLab CI