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.
Different tiers run on different branches. Keeps PRs fast. Catches everything before production.
Each tier maps to specific skills. Each environment has a different severity blocking policy.
| 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 |
| Env | Critical | High | Medium | Low |
|---|---|---|---|---|
| PR | ● Block | ● Warn | ○ Info | ○ Info |
| Staging | ● Block | ● Block | ● Warn | ○ Info |
| Prod | ● Block | ● Block | ● Block | ● Warn |
Check these six requirements. If you already have a typical GitHub setup, most will be green.
console.anthropic.com. Added as a repo secret.ubuntu-latest. Nothing to configure.feature/* → staging → main. Adapt workflow triggers if yours differs.Five workflow files, one composite action, a severity matrix, and a shell helper. All live under .github/ and scripts/.
Copy-paste ready. Each file has a single job: wire the right tiers to the right branch events.
# ─────────────────────────────────────────────────────────────
# 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
# ─────────────────────────────────────────────────────────────
# 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.
# ─────────────────────────────────────────────────────────────
# 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 }}
# ─────────────────────────────────────────────────────────────
# 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.
# ─────────────────────────────────────────────────────────────
# 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 }}
The composite action, severity matrix, and bash helper that power all 5 workflows.
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
{
"$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 }
}
}
#!/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"
Seven steps. Start to first green check.
Go to Repo → Settings → Secrets and variables → Actions → New repository secret and add:
ANTHROPIC_API_KEY — required. Generate at console.anthropic.comCHAT_WEBHOOK — optional. Google Chat incoming webhook URL for notificationsSECURITY_EMAIL — optional. Security team email address for critical alerts${{ secrets.ANTHROPIC_API_KEY }}.
Clone the heaptrace-skills repo, then copy the security config into your own repo:
./.github/actions/security-tier depends on it.
Go to Settings → Branches → Add rule and create one for main:
Security Gate — ProductionThen add a rule for staging:
Security Gate — StagingThis is what gives you the manual approval gate before production deploys.
production (lowercase — matches environment: production in the workflow)0 (or 5 for a "sleep on it" buffer)production-approval job will run automatically with no human gate.
Stage and push the security files. GitHub Actions picks them up on the next push.
If Actions is disabled on your repo, enable it now.
Open a test PR to sanity-check everything is wired correctly:
Within 2 minutes you should see:
Security Gate — PR check appears on the PRFour scenarios to prove every tier is wired correctly.
STRIPE_KEY=sk_live_test123 added to a file.security-pr.yml · Tier 1 onlynpm install lodash@4.17.11 (known CVE-2021-23337) and open a PR.security-pr.yml · Tier 1 (dep-vuln skill)Dockerfile (add a new ENV line), open PR to staging.security-staging.yml · Tiers 1 + 2 + 3 (path filter detected infra)main.security-deep-scan.yml · All 5 tiers, full historyWhen something breaks, check these six first.
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.
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.
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 pathsInspect the changed-files job output in the Actions tab to see exactly what paths the filter saw.
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.
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.
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.
Four common recipes. The system is designed to be tweaked.
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.
.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.
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.
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.