PortGate

Blueprints · Docker & Databases

Beginner 15 min · GitHub Actions

Trivy image scan in GitHub Actions

Builds the image in CI and fails the job when Trivy reports a critical or high finding. The scan does not deploy.

Live config

Baked-in protections

Step 1 · yaml

Workflow

.github/workflows/trivy.yml

Commit this under .github/workflows. Add a deploy job only after this one succeeds.

name: trivy
on:
  push:
    branches: [main]
jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build
        run: docker build -t app:scan .
      - name: Scan
        uses: aquasecurity/[email protected]
        with:
          image-ref: app:scan
          format: table
          exit-code: "1"
          severity: CRITICAL,HIGH
          ignore-unfixed: true

Step 2 · text

Review note

.trivyignore

Unfixed findings fail the job. Record a reviewed exception here only after you accept the residual risk.

# CVE-EXAMPLE-0000
# Reason and expiry. An empty file fails the build on every unfixed critical or high finding.