Setup Guide

Set Up Tiered Security
in Your GitHub Repo

Step-by-step guide to installing 5 GitHub Actions workflows, a composite action, and a severity matrix — turning the Compliance Pack into an automated security gateway that runs on every PR.

5
Workflows
$0
Runtime Cost
GH Actions
Zero Vendor Lock-in
Architecture

Tiered Architecture

Different tiers run on different branches. Keeps PRs fast. Catches everything before production.

feature/*
↓
PR
↓
Fast Gate
< 2 min
T1
develop
↓
staging
↓
Staging Gate
7 – 10 min
T1 T2 T3*
staging
↓
main
↓
Full Scan
~ 20 min
T1 T2 T3 T4 T5
main
↓
production
↓
Approval + Deploy
Manual gate
T1 T2 T3 T4 T5
Matrix

What Runs Where

Each tier maps to specific skills. Each environment has a different severity blocking policy.

A · Tier → Skill Mapping
Tier Speed Skills When
1 · Fast Gate <2 min secrets-scan
dep-vuln
Every PR
2 · Code Security ~5 min sec-audit
privacy-review
access-audit
audit-log
PR → staging
3 · Infrastructure ~8 min cloud-security
infra-harden
network-audit
Infra changed
4 · Compliance ~15 min hipaa-audit
gdpr-audit
soc2-audit
pci-audit
Push → main
5 · Reporting ~3 min compliance-report
incident-plan
Scheduled + main
B · Severity Blocking Policy
Env Critical High Medium Low
PR ● Block ● Warn ○ Info ○ Info
Staging ● Block ● Block ● Warn ○ Info
Prod ● Block ● Block ● Block ● Warn
● Block — fail the job · ● Warn — post comment, pass · ○ Info — log only
Prerequisites

Before You Start

Check these six requirements. If you already have a typical GitHub setup, most will be green.

✓
GitHub Actions enabled
Actions tab available on your repo. Enable in Settings → Actions → General if disabled.
✓
ANTHROPIC_API_KEY
Generate one at console.anthropic.com. Added as a repo secret.
✓
Node.js 20+ runners
Default on ubuntu-latest. Nothing to configure.
✓
Branch structure
Typical flow: feature/* → staging → main. Adapt workflow triggers if yours differs.
✓
Branch protection rights
You need repo admin to configure branch protection and require status checks.
!
Google Chat webhook (optional)
For notifications. Skip if you'd rather stick with GitHub comments and email.
Files

What You'll Add to Your Repo

Five workflow files, one composite action, a severity matrix, and a shell helper. All live under .github/ and scripts/.

.github/ ├── workflows/ │ ├── security-pr.yml ← Tier 1 only (every PR) │ ├── security-staging.yml ← Tiers 1+2 (+3 if infra changed) │ ├── security-production.yml ← ALL tiers + manual approval │ ├── security-deep-scan.yml ← Weekly scheduled scan │ └── security-demand.yml ← Manual on-demand runs ├── actions/ │ └── security-tier/ │ └── action.yml ← Composite action (reusable) └── security/ └── severity-matrix.json ← Blocking policy config scripts/ └── security/ └── run-tier.sh ← Bash helper (tier runner)
Workflows

The 5 Workflow Files

Copy-paste ready. Each file has a single job: wire the right tiers to the right branch events.

.github/workflows/security-pr.yml
Runs Tier 1 (secrets + dep vuln) on every pull request. Fastest gate — blocks only on CRITICAL findings.
< 2 min
security-pr.yml
# ─────────────────────────────────────────────────────────────
# Security Gate — PR (Tier 1: Fast Gate)
# Triggers on every pull request to any branch.
# Runs only the fastest checks: secrets-scan + dep-vuln.
# Blocks merge only on CRITICAL findings. Warns on HIGH.
# Target duration: < 2 minutes.
# ─────────────────────────────────────────────────────────────
name: Security Gate — PR

on:
  pull_request:
    branches: ['**']

concurrency:
  group: security-pr-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read
  pull-requests: write
  checks: write

jobs:
  tier-1-fast-gate:
    name: Tier 1 — Fast Gate
    runs-on: ubuntu-latest
    timeout-minutes: 5
    outputs:
      max-severity: ${{ steps.run.outputs.max-severity }}
      findings-count: ${{ steps.run.outputs.findings-count }}
      report-path: ${{ steps.run.outputs.report-path }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0   # full history for secrets-scan
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - name: Run Tier 1 security checks
        id: run
        uses: ./.github/actions/security-tier
        with:
          tier: '1'
          skills: 'secrets-scan,dep-vuln'
          environment: 'PR'
          severity-config: '.github/security/severity-matrix.json'
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: security-pr-report-${{ github.sha }}
          path: ${{ steps.run.outputs.report-path }}
          retention-days: 30
      - name: Post findings to PR
        if: always() && github.event_name == 'pull_request'
        uses: actions/github-script@v7
        # (see repo for full script body — posts a rich PR comment
        #  with findings grouped by severity and skill)
      - name: Enforce severity policy
        if: always()
        run: |
          if [ "${{ steps.run.outputs.blocked }}" = "true" ]; then
            echo "::error::Security gate BLOCKED"
            exit 1
          fi
.github/workflows/security-staging.yml
Runs Tiers 1 + 2 on PRs to staging. Adds Tier 3 only when infra files are changed (detected via path filter).
~ 7 min
security-staging.yml
# ─────────────────────────────────────────────────────────────
# Security Gate — Staging (Tiers 1+2, +3 conditional)
# On PRs to staging and pushes to develop.
# Target duration: ~7 minutes (~10 if infra files changed).
# ─────────────────────────────────────────────────────────────
name: Security Gate — Staging

on:
  pull_request:
    branches: [staging]
  push:
    branches: [develop]

concurrency:
  group: security-staging-${{ github.ref }}
  cancel-in-progress: false

permissions:
  contents: read
  pull-requests: write
  checks: write

jobs:
  # ── Detect whether infra files changed ───────────────────────
  changed-files:
    name: Detect changed paths
    runs-on: ubuntu-latest
    outputs:
      infra: ${{ steps.filter.outputs.infra }}
    steps:
      - uses: actions/checkout@v4
      - uses: dorny/paths-filter@v3
        id: filter
        with:
          filters: |
            infra:
              - 'Dockerfile*'
              - 'docker-compose*.yml'
              - 'terraform/**'
              - 'kubernetes/**'
              - '.github/workflows/**'
              - '**/*.tf'
              - '**/nginx*.conf'

  # ── Tiers 1 + 2: always run ─────────────────────────────────
  tier-1-2:
    name: Tiers 1 + 2 — Fast + Code
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/security-tier
        with:
          tier: '1,2'
          skills: 'secrets-scan,dep-vuln,sec-audit,privacy-review,access-audit,audit-log'
          environment: 'staging'
          severity-config: '.github/security/severity-matrix.json'
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

  # ── Tier 3: only if infra changed ───────────────────────────
  tier-3-infra:
    name: Tier 3 — Infrastructure
    needs: [changed-files]
    if: needs.changed-files.outputs.infra == 'true'
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/security-tier
        with:
          tier: '3'
          skills: 'cloud-security,infra-harden,network-audit'
          environment: 'staging'
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

  # ── Finalize: aggregate + notify ────────────────────────────
  finalize:
    name: Aggregate & Notify
    needs: [tier-1-2, tier-3-infra]
    if: always()
    runs-on: ubuntu-latest
    steps:
      - name: Post to Google Chat
        if: env.CHAT_WEBHOOK != ''
        env:
          CHAT_WEBHOOK: ${{ secrets.CHAT_WEBHOOK }}
        run: |
          curl -X POST -H 'Content-Type: application/json' \
            -d "{\"text\": \"Staging security scan: ${{ job.status }}\"}" \
            "$CHAT_WEBHOOK"

# Full file with rich Chat Card v2 payload lives in the heaptrace-skills repo.
.github/workflows/security-production.yml
Runs ALL 5 tiers on push/PR to main. Requires manual approval before deploy. Fullest coverage, slowest duration.
~ 20 min
security-production.yml
# ─────────────────────────────────────────────────────────────
# Security Gate — Production (ALL 5 Tiers + Manual Approval)
# On push/PR to main. Target duration: ~20 minutes.
# Requires manual approval via the 'production' environment.
# ─────────────────────────────────────────────────────────────
name: Security Gate — Production

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

concurrency:
  group: security-prod-${{ github.ref }}
  cancel-in-progress: false

permissions:
  contents: read
  pull-requests: write
  issues: write
  checks: write

jobs:
  # ── Tiers 1 + 2: parallel ────────────────────────────────────
  tier-1-2:
    name: Tiers 1+2 — Fast + Code Security
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/security-tier
        with:
          tier: '1,2'
          skills: 'secrets-scan,dep-vuln,sec-audit,privacy-review,access-audit,audit-log'
          environment: 'production'
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

  # ── Tier 3: always on prod (parallel to 1+2) ─────────────────
  tier-3:
    name: Tier 3 — Infrastructure
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/security-tier
        with:
          tier: '3'
          skills: 'cloud-security,infra-harden,network-audit'
          environment: 'production'
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

  # ── Tier 4: compliance frameworks (after 1+2) ────────────────
  tier-4-frameworks:
    name: Tier 4 — Compliance Frameworks
    needs: [tier-1-2]
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/security-tier
        with:
          tier: '4'
          skills: 'hipaa-audit,gdpr-audit,soc2-audit,pci-audit'
          environment: 'production'
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

  # ── Tier 5: aggregate report (downloads all prior artifacts) ─
  tier-5-report:
    name: Tier 5 — Report & Incident Plan
    needs: [tier-1-2, tier-3, tier-4-frameworks]
    if: always()
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/download-artifact@v4
        with:
          path: ./reports
      - uses: ./.github/actions/security-tier
        with:
          tier: '5'
          skills: 'compliance-report,incident-plan'
          environment: 'production'
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

  # ── Manual approval gate before deploy ───────────────────────
  production-approval:
    name: Production Approval
    needs: [tier-5-report]
    runs-on: ubuntu-latest
    environment: production   # ← required reviewers defined in repo settings
    steps:
      - run: echo "All 5 tiers passed. Approved for production."

  # ── Finalize: email + Chat ───────────────────────────────────
  finalize:
    name: Notify
    needs: [production-approval]
    if: always()
    runs-on: ubuntu-latest
    steps:
      - run: echo "Post to Chat + send email to $SECURITY_EMAIL"
        env:
          CHAT_WEBHOOK: ${{ secrets.CHAT_WEBHOOK }}
          SECURITY_EMAIL: ${{ secrets.SECURITY_EMAIL }}
.github/workflows/security-deep-scan.yml
Scheduled weekly (Sundays 02:00 UTC). Runs all tiers across full history. Opens GitHub issues for new findings.
Weekly · Cron
security-deep-scan.yml
# ─────────────────────────────────────────────────────────────
# Security Gate — Deep Scan (scheduled weekly)
# Sundays @ 02:00 UTC. Full history, all tiers, opens issues.
# ─────────────────────────────────────────────────────────────
name: Security Gate — Deep Scan

on:
  schedule:
    - cron: '0 2 * * 0'   # Sunday 02:00 UTC
  workflow_dispatch:

permissions:
  contents: read
  issues: write

jobs:
  deep-scan:
    name: Deep Scan — All Tiers
    runs-on: ubuntu-latest
    timeout-minutes: 45
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0   # FULL history for deep secrets-scan
      - uses: ./.github/actions/security-tier
        with:
          tier: '1,2,3,4,5'
          skills: 'secrets-scan,dep-vuln,sec-audit,privacy-review,access-audit,audit-log,cloud-security,infra-harden,network-audit,hipaa-audit,gdpr-audit,soc2-audit,pci-audit,compliance-report,incident-plan'
          environment: 'production'
          history-days: 'all'
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

      - name: Open GitHub issues for new findings
        if: always()
        uses: actions/github-script@v7
        with:
          script: |
            // Reads reports/findings.json and opens one issue per
            // CRITICAL or HIGH finding, labeled [security, deep-scan].
            // Deduplicates by fingerprint hash to avoid spam.
.github/workflows/security-demand.yml
Manual trigger via Actions UI. Pick tier(s) + severity profile and run on demand. Useful for one-off audits.
Manual
security-demand.yml
# ─────────────────────────────────────────────────────────────
# Security Gate — On-Demand (manual trigger)
# Run any tier combination against any severity profile.
# ─────────────────────────────────────────────────────────────
name: Security Gate — On-Demand

on:
  workflow_dispatch:
    inputs:
      tier:
        description: 'Tier(s) to run'
        required: true
        default: '1,2'
        type: choice
        options:
          - '1'
          - '1,2'
          - '1,2,3'
          - '4'
          - '5'
          - 'all'
      severity-profile:
        description: 'Severity profile (determines blocking)'
        required: true
        default: 'staging'
        type: choice
        options: [PR, staging, production]

permissions:
  contents: read
  checks: write

jobs:
  # Resolve the 'tier' input to a concrete skill list ──────────
  resolve:
    name: Resolve skills for tier
    runs-on: ubuntu-latest
    outputs:
      skills: ${{ steps.map.outputs.skills }}
    steps:
      - id: map
        run: |
          case "${{ github.event.inputs.tier }}" in
            1)     echo "skills=secrets-scan,dep-vuln" >> "$GITHUB_OUTPUT" ;;
            1,2)   echo "skills=secrets-scan,dep-vuln,sec-audit,privacy-review,access-audit,audit-log" >> "$GITHUB_OUTPUT" ;;
            1,2,3) echo "skills=secrets-scan,dep-vuln,sec-audit,privacy-review,access-audit,audit-log,cloud-security,infra-harden,network-audit" >> "$GITHUB_OUTPUT" ;;
            4)     echo "skills=hipaa-audit,gdpr-audit,soc2-audit,pci-audit" >> "$GITHUB_OUTPUT" ;;
            5)     echo "skills=compliance-report,incident-plan" >> "$GITHUB_OUTPUT" ;;
            all)   echo "skills=secrets-scan,dep-vuln,sec-audit,privacy-review,access-audit,audit-log,cloud-security,infra-harden,network-audit,hipaa-audit,gdpr-audit,soc2-audit,pci-audit,compliance-report,incident-plan" >> "$GITHUB_OUTPUT" ;;
          esac

  run-tier:
    name: Run Tier ${{ github.event.inputs.tier }}
    needs: [resolve]
    runs-on: ubuntu-latest
    timeout-minutes: 45
    steps:
      - uses: actions/checkout@v4
      - uses: ./.github/actions/security-tier
        with:
          tier: ${{ github.event.inputs.tier }}
          skills: ${{ needs.resolve.outputs.skills }}
          environment: ${{ github.event.inputs.severity-profile }}
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
Config

Supporting Configuration

The composite action, severity matrix, and bash helper that power all 5 workflows.

.github/actions/security-tier/action.yml
Composite action invoked by all 5 workflows. Installs Claude Code + gitleaks + trivy, then runs the bash helper.
Composite
action.yml
name: 'Security Tier Runner'
description: 'Runs one or more security tiers using the Heaptrace Skills compliance pack.'

inputs:
  tier:
    description: 'Tier ID(s): 1, 1,2, 1,2,3, 4, 5, or all'
    required: true
  skills:
    description: 'Comma-separated list of skills to invoke'
    required: true
  environment:
    description: 'Severity profile: PR | staging | production'
    required: true
  severity-config:
    description: 'Path to severity-matrix.json'
    required: false
    default: '.github/security/severity-matrix.json'
  history-days:
    description: "Git history window: 'all' or number of days"
    required: false
    default: '30'
  anthropic-api-key:
    description: 'Anthropic API key (secret)'
    required: true

outputs:
  max-severity:
    description: 'Highest severity encountered: CRITICAL | HIGH | MEDIUM | LOW | NONE'
    value: ${{ steps.run.outputs.max-severity }}
  findings-count:
    description: 'Total number of findings across all skills'
    value: ${{ steps.run.outputs.findings-count }}
  report-path:
    description: 'Path to the consolidated JSON report'
    value: ${{ steps.run.outputs.report-path }}
  blocked:
    description: 'true if the severity policy blocks this run'
    value: ${{ steps.run.outputs.blocked }}

runs:
  using: 'composite'
  steps:
    - name: Install Claude Code CLI
      shell: bash
      run: npm install -g @anthropic-ai/claude-code

    - name: Install gitleaks + trivy
      shell: bash
      run: |
        curl -sSfL https://raw.githubusercontent.com/gitleaks/gitleaks/master/install.sh | sh -s -- -b /usr/local/bin
        curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin

    - name: Install Heaptrace compliance pack
      shell: bash
      run: |
        mkdir -p ~/.claude/skills
        curl -sSfL https://github.com/heaptracetechnology/heaptrace-skills/releases/latest/download/compliance-pack.tar.gz \
          | tar -xz -C ~/.claude/skills

    - name: Run tier runner
      id: run
      shell: bash
      env:
        ANTHROPIC_API_KEY: ${{ inputs.anthropic-api-key }}
        TIER: ${{ inputs.tier }}
        SKILLS: ${{ inputs.skills }}
        ENVIRONMENT: ${{ inputs.environment }}
        SEVERITY_CONFIG: ${{ inputs.severity-config }}
        HISTORY_DAYS: ${{ inputs.history-days }}
      run: bash scripts/security/run-tier.sh
.github/security/severity-matrix.json
Declarative policy. Maps each environment + severity level to an action (block / warn / info). Also weights each skill.
JSON
severity-matrix.json
{
  "$schema": "https://heaptrace.com/schema/severity-matrix-v1.json",
  "version": "1.0",
  "description": "Blocking policy for the tiered security pipeline.",

  "environments": {
    "PR": {
      "CRITICAL": "block",
      "HIGH":     "warn",
      "MEDIUM":   "info",
      "LOW":      "info"
    },
    "staging": {
      "CRITICAL": "block",
      "HIGH":     "block",
      "MEDIUM":   "warn",
      "LOW":      "info"
    },
    "production": {
      "CRITICAL": "block",
      "HIGH":     "block",
      "MEDIUM":   "block",
      "LOW":      "warn"
    }
  },

  "skill_weights": {
    "secrets-scan":     10,
    "dep-vuln":         8,
    "sec-audit":        8,
    "privacy-review":   7,
    "access-audit":     7,
    "audit-log":        5,
    "cloud-security":   9,
    "infra-harden":     8,
    "network-audit":    7,
    "hipaa-audit":      9,
    "gdpr-audit":       9,
    "soc2-audit":       8,
    "pci-audit":        9,
    "compliance-report": 3,
    "incident-plan":    3
  },

  "notifications": {
    "chat":  { "on": ["CRITICAL", "HIGH"] },
    "email": { "on": ["CRITICAL"] },
    "issue": { "on": ["CRITICAL", "HIGH"], "deduplicate": true }
  }
}
scripts/security/run-tier.sh
The engine. Loops through each skill, invokes Claude Code, extracts JSON findings, applies severity thresholds.
Bash
run-tier.sh
#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────
# scripts/security/run-tier.sh
# Runs a comma-separated list of compliance skills, extracts
# findings, applies the severity matrix, and emits outputs.
# Env: TIER, SKILLS, ENVIRONMENT, SEVERITY_CONFIG, HISTORY_DAYS,
#      ANTHROPIC_API_KEY (see action.yml)
# ─────────────────────────────────────────────────────────────
set -euo pipefail

# Severity ranking (bash associative array)
declare -A RANK=(
  [NONE]=0 [LOW]=1 [MEDIUM]=2 [HIGH]=3 [CRITICAL]=4
)

REPORT_DIR="reports"
mkdir -p "$REPORT_DIR"
ALL_FINDINGS="$REPORT_DIR/findings.json"
echo "[]" > "$ALL_FINDINGS"

MAX_SEV="NONE"

# ── Loop skills ──────────────────────────────────────────────
IFS=',' read -ra SKILL_LIST <<< "$SKILLS"
for SKILL in "${SKILL_LIST[@]}"; do
  SKILL="${SKILL// /}"
  echo "::group::Running /${SKILL}"

  OUT="$REPORT_DIR/${SKILL}.json"

  # Invoke Claude Code — headless, JSON output
  claude -p "Run the /${SKILL} skill. Emit findings as JSON only, schema: [{severity, title, file, line, remediation}]" \
    --output-format json \
    --max-tokens 8000 \
    --timeout 600 \
    > "$OUT" || true

  # Extract the findings array with awk (first [...] block)
  awk '/\[/{flag=1} flag; /\]/{flag=0; exit}' "$OUT" \
    | jq -c '.' > "$OUT.clean" && mv "$OUT.clean" "$OUT"

  # Merge into aggregate findings
  jq -s '[.[0], .[1]] | add' "$ALL_FINDINGS" "$OUT" > "$ALL_FINDINGS.tmp"
  mv "$ALL_FINDINGS.tmp" "$ALL_FINDINGS"

  # Track highest severity
  SKILL_MAX=$(jq -r '[.[].severity // "NONE"] | max_by(.) // "NONE"' "$OUT")
  if [ "${RANK[$SKILL_MAX]:-0}" -gt "${RANK[$MAX_SEV]:-0}" ]; then
    MAX_SEV="$SKILL_MAX"
  fi

  echo "::endgroup::"
done

# ── Apply severity policy ────────────────────────────────────
ACTION=$(jq -r ".environments.\"$ENVIRONMENT\".\"$MAX_SEV\" // \"info\"" "$SEVERITY_CONFIG")
COUNT=$(jq -r 'length' "$ALL_FINDINGS")

BLOCKED="false"
if [ "$ACTION" = "block" ]; then
  BLOCKED="true"
fi

# ── Emit outputs for the composite action ────────────────────
{
  echo "max-severity=$MAX_SEV"
  echo "findings-count=$COUNT"
  echo "report-path=$ALL_FINDINGS"
  echo "blocked=$BLOCKED"
} >> "$GITHUB_OUTPUT"

echo "✓ Tier $TIER complete: $COUNT findings · max=$MAX_SEV · action=$ACTION"
Setup

Step-by-Step GitHub Setup

Seven steps. Start to first green check.

1
Add Repository Secrets

Go to Repo → Settings → Secrets and variables → Actions → New repository secret and add:

  • ANTHROPIC_API_KEY — required. Generate at console.anthropic.com
  • CHAT_WEBHOOK — optional. Google Chat incoming webhook URL for notifications
  • SECURITY_EMAIL — optional. Security team email address for critical alerts
✓ Secrets are repo-level, not environment-level. Workflows reference them as ${{ secrets.ANTHROPIC_API_KEY }}.
2
Copy Files into Your Repo

Clone the heaptrace-skills repo, then copy the security config into your own repo:

git clone https://github.com/heaptracetechnology/heaptrace-skills.git cd heaptrace-skills # Into your project cp -r .github/workflows/security-*.yml ../your-repo/.github/workflows/ cp -r .github/actions/security-tier ../your-repo/.github/actions/ cp -r .github/security ../your-repo/.github/ cp -r scripts/security ../your-repo/scripts/ chmod +x ../your-repo/scripts/security/run-tier.sh
✓ Keep the exact paths. The composite action reference ./.github/actions/security-tier depends on it.
3
Configure Branch Protection

Go to Settings → Branches → Add rule and create one for main:

  • Require a pull request before merging — enabled
  • Require approvals — 1 or more
  • Require status checks to pass → add Security Gate — Production
  • Require branches to be up to date — enabled

Then add a rule for staging:

  • Require status checks → Security Gate — Staging
  • Allow force pushes — disabled
4
Set Up Production Environment

This is what gives you the manual approval gate before production deploys.

  • Go to Settings → Environments → New environment
  • Name it exactly production (lowercase — matches environment: production in the workflow)
  • Under Required reviewers, add 1–6 security team members
  • Wait timer: 0 (or 5 for a "sleep on it" buffer)
✓ Without this, the production-approval job will run automatically with no human gate.
5
Commit and Push

Stage and push the security files. GitHub Actions picks them up on the next push.

git add .github scripts git commit -m "feat: add tiered security gateway workflows" git push origin main
6
Enable GitHub Actions

If Actions is disabled on your repo, enable it now.

  • Settings → Actions → General
  • Under Actions permissions select "Allow all actions and reusable workflows"
  • Under Workflow permissions select "Read and write permissions" (so workflows can post PR comments and open issues)
7
Verify the Setup

Open a test PR to sanity-check everything is wired correctly:

git checkout -b test/security-gate echo 'API_KEY=sk_test_12345_for_demo_only' >> .env.example git commit -am "test: intentional secret to trigger scan" git push origin test/security-gate # then open a PR to staging on GitHub

Within 2 minutes you should see:

  • Security Gate — PR check appears on the PR
  • Bot comment listing the CRITICAL secret finding
  • Merge blocked — exactly as expected
✓ Remove the test commit before merging. You're live.
Testing

How to Test Each Pipeline

Four scenarios to prove every tier is wired correctly.

Test A · PR
Secret leaked in a PR
Setup
Create a PR with STRIPE_KEY=sk_live_test123 added to a file.
Triggers
security-pr.yml · Tier 1 only
Expected
PR check fails. Bot posts a comment listing the CRITICAL finding with file/line. Merge button disabled.
Test B · PR
Vulnerable dependency
Setup
Run npm install lodash@4.17.11 (known CVE-2021-23337) and open a PR.
Triggers
security-pr.yml · Tier 1 (dep-vuln skill)
Expected
HIGH warning in PR comment. Merge not blocked (HIGH → warn on PR, per severity matrix).
Test C · Staging
Infrastructure change
Setup
Modify Dockerfile (add a new ENV line), open PR to staging.
Triggers
security-staging.yml · Tiers 1 + 2 + 3 (path filter detected infra)
Expected
All three jobs run in parallel. Report returned within 10 min. Tier 3 skipped if you change only app code.
Test D · Manual
Manual deep scan
Setup
Actions tab → "Security Gate — Deep Scan" → Run workflow → branch main.
Triggers
security-deep-scan.yml · All 5 tiers, full history
Expected
~40 min run time. GitHub Issues opened for each new CRITICAL/HIGH finding. Email sent to security team.
Troubleshooting

Common Issues

When something breaks, check these six first.

1 Workflow doesn't run at all

Check three things in order:

1. Actions enabled — Go to Settings → Actions → General. "Allow all actions" must be selected.

2. Trigger match — The workflow's on: block must match your event. E.g. on: pull_request: branches: [staging] requires a PR targeting staging, not main.

3. Secrets set — Missing ANTHROPIC_API_KEY causes the run to fail instantly. Check Settings → Secrets and variables → Actions.

If all three check out, view the workflow in the Actions tab — GitHub shows exactly why a run was skipped.

2 "ANTHROPIC_API_KEY not set" error

The secret must be at repository level, not environment level — workflows without environment: can't see environment secrets.

Also check the exact name: ANTHROPIC_API_KEY is case-sensitive. anthropic_api_key or ANTHROPIC-API-KEY will fail.

If this is a fork, note that secrets are not passed to workflows run from forks by default — this is a security feature. Contributors need to open PRs from branches within the repo.

3 Path filter not triggering Tier 3

Verify the file paths you changed match the glob patterns in dorny/paths-filter. Common traps:

  • • terraform/** matches terraform/main.tf but not infra/terraform/main.tf
  • • **/*.tf is broader — use that if you keep Terraform in non-standard paths
  • • Added new kinds of infra (e.g. Pulumi, Helm)? Add those paths to the filter

Inspect the changed-files job output in the Actions tab to see exactly what paths the filter saw.

4 Report artifact is missing

The upload step is guarded with if: always() — it should upload even on failures. If the artifact is still missing:

• The job's timeout-minutes may have hit before the upload step ran. Check Tier 4's 20-minute timeout — compliance skills are the slowest.

• The per-skill timeout inside run-tier.sh is --timeout 600 (10 min). On a large codebase, HIPAA/GDPR audits can exceed this. Raise to 1200 if needed.

• report-path output resolves to reports/findings.json — confirm the file exists via ls reports/ in a debug step.

5 Production approval never appears

The GitHub production environment must exist and have required reviewers assigned. Both conditions, not either.

Go to Settings → Environments. If production isn't there, create it. Then click into it and add reviewers under "Required reviewers". Approval will show up on the very next run.

The environment name is case-sensitive and must match the workflow's environment: production key exactly.

6 Google Chat notification failed

The Chat step is fenced by if: env.CHAT_WEBHOOK != '' — a missing secret silently skips it.

• Confirm CHAT_WEBHOOK is set at repo level (Settings → Secrets and variables → Actions)

• The URL should look like https://chat.googleapis.com/v1/spaces/AAAA.../messages?key=...&token=...

• Test the URL manually: curl -X POST -H 'Content-Type: application/json' -d '{"text":"test"}' "$CHAT_WEBHOOK"

• Chat webhooks stop working if the space is deleted or the bot is removed — regenerate if so.

Customize

Customize the Pipeline

Four common recipes. The system is designed to be tweaked.

A
Add or remove a skill from a tier
Edit the target workflow's skills: input (comma-separated). For example, to drop audit-log from staging's Tier 1+2 job, remove it from the list in security-staging.yml. Re-deploy — no other changes needed.
B
Change severity policy
Edit .github/security/severity-matrix.json. To make PRs stricter — e.g., block on HIGH as well as CRITICAL — change "PR": { "HIGH": "warn" } to "PR": { "HIGH": "block" }. Takes effect on the next run.
C
Add a custom skill
Drop your SKILL.md into the compliance/ folder of the pack. Add the skill's slug to the relevant tier's skills: list. It runs automatically — no code change in run-tier.sh required, since the loop is data-driven.
D
Change report destination
S3 archive: add an aws-actions/configure-aws-credentials step (OIDC role), then aws s3 cp the report after the tier runs. Slack: replace the Chat webhook step with a Slack Incoming Webhook call. Email only: drop the Chat step and keep the mail command.

Get the Full Setup from GitHub

All 5 workflows, the composite action, severity matrix, and helper script are committed to the heaptrace-skills repo. Clone and copy into your project.

Clone from GitHub Back to Overview