Skip to content

scan-trivy.yml

Run Trivy vulnerability scans on container images and/or configuration files and upload SARIF reports to GitHub Security.

Inputs

InputTypeDescriptionRequiredDefault
IMAGEstringImage used to perform scan (e.g., docker.io/debian:latest)No-
REGISTRY_USERNAMEstringUsername used to login into registryNo-
REGISTRY_PASSWORDstringPassword used to login into registryNo-
PATHstringPath used to perform config scanNo-
FORMATstringFormat of the report (sarif, table, json, ...)Notable
PR_NUMBERstringPR number for comment postingNo-
GITHUB_SECURITY_TABbooleanWhether to upload SARIF to GitHub Security TabNofalse

Permissions

ScopeAccessDescription
contentsreadRead repository contents
security-eventswriteUpload SARIF to code scanning
pull-requestswritePost a comment on the pull request
packagesreadPull images from GHCR

Notes

  • images-scan runs only if IMAGE is provided; config-scan runs only if PATH is provided.
  • FORMAT controls output format: table (default) prints results to workflow summary, sarif enables GitHub Security Tab integration.
  • When GITHUB_SECURITY_TAB: true and FORMAT: sarif, uploads results to the Security tab.
  • PR comments link to either the GitHub Security Tab (when GITHUB_SECURITY_TAB: true) or the Workflow Summary page.
  • Registry authentication: uses GitHub token for ghcr.io, otherwise uses provided credentials.
  • Skips common directories via skip-dirs: **/node_modules in config scan.

Examples

Simple scan with table output

yaml
jobs:
  vuln-scan:
    uses: this-is-tobi/github-workflows/.github/workflows/scan-trivy.yml@main
    with:
      IMAGE: ghcr.io/my-org/my-image:1.2.3
      PATH: ./apps/api
      FORMAT: table
      PR_NUMBER: ${{ github.event.pull_request.number }}

Scan with GitHub Security Tab integration

yaml
jobs:
  vuln-scan:
    uses: this-is-tobi/github-workflows/.github/workflows/scan-trivy.yml@main
    with:
      IMAGE: ghcr.io/my-org/my-image:1.2.3
      PATH: ./apps/api
      FORMAT: sarif
      GITHUB_SECURITY_TAB: true
      PR_NUMBER: ${{ github.event.pull_request.number }}