Integrate SAST, SCA and Container Scanning into your GitHub Actions workflow

Modern GitHub workflows should catch vulnerabilities as early as possible. A practical, recent approach is to combine three complementary scans inside your CI: semantic static analysis (SAST) with CodeQL, dependency-supply-chain checks with Dependabot (SCA), and container/image scanning with Trivy — plus SBOM generation to make results auditable. The rest of this article explains why that combo works and shows a compact GitHub Actions example you can adapt. (docs.github.com)

Why this trio?

Adding SBOM generation (for example with Syft via the anchore/sbom-action) creates a machine-readable inventory of components that other tools (or auditors) can consume. Anchore’s SBOM action runs Syft and can upload SBOM artifacts from the workflow. (github.com)

Key safety notes (non-negotiable)

Example setup: files you’ll add

Below are compact examples showing:

dependabot.yml (place in .github/dependabot.yml)

version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "daily"
    open-pull-requests-limit: 5
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "daily"
    reviewers: ["team-security"]

(Dependabot will raise PRs for vulnerable packages and for actions in workflows when configured.) (docs.github.com)

.github/workflows/security-pipeline.yml (simplified)

name: Security pipeline
on: [push, pull_request]

permissions:
  contents: read
  security-events: write
  packages: read

jobs:
  codeql:
    name: CodeQL analysis
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v3
        with:
          languages: javascript,python
      - name: Perform CodeQL analysis
        uses: github/codeql-action/analyze@v3

  sbom:
    name: Generate SBOM
    runs-on: ubuntu-latest
    needs: codeql
    steps:
      - uses: actions/checkout@v4
      - name: Generate SBOM (Syft via Anchore action)
        uses: anchore/sbom-action@sha256:<IMMUTABLE_SHA>
        with:
          output-file: sbom.spdx.json
      - name: Upload SBOM artifact
        uses: actions/upload-artifact@v4
        with:
          name: sbom
          path: sbom.spdx.json

  trivy:
    name: Container scan
    runs-on: ubuntu-latest
    needs: sbom
    steps:
      - uses: actions/checkout@v4
      - name: Build image
        run: docker build -t $:pr-$ .
      - name: Trivy scan image
        uses: aquasecurity/trivy-action@sha256:<IMMUTABLE_SHA>
        with:
          image-ref: $:pr-$
          format: sarif
          output: trivy.sarif
      - name: Upload Trivy SARIF
        uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: trivy.sarif

Notes:

How this workflow fits into pull requests

Practical tuning tips

Quick checklist before enabling this in a repo

Combining CodeQL, Dependabot, Trivy, and SBOMs gives layered coverage: semantic code problems, vulnerable dependencies, image-level CVEs, and an auditable inventory of components. That combination reduces surprise during release and makes it much easier for developers and security teams to act on findings inside the natural GitHub workflow. (docs.github.com)