# Generated by /setup-meerkat — safe to delete; re-run the skill to recreate it.
#
# Arm: secret scan (gitleaks). History matters: a credential deleted from HEAD is
# still leaked, so the checkout keeps the full history.
#
# The MIT-licensed CLI runs from the published image — `gitleaks-action` needs a
# license key on organization accounts, the CLI does not. Its exit code is the gate:
# a committed secret fails this job. A secret is never waivered the way an advisory
# is: rotate it, purge it from the history, then record what happened.
#
# Every `uses:` ref below is pinned to the commit this skill shipped with. Re-check
# them when you upgrade the skill.

name: security-secret-scan

on:
  pull_request:
  schedule:
    - cron: "17 3 * * 1"
  workflow_dispatch:

permissions:
  contents: read

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

jobs:
  secret-scan:
    name: Secret scan (gitleaks)
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
        with:
          fetch-depth: 0

      - name: gitleaks (tree and history)
        run: |
          set -euo pipefail
          docker run --rm -v "$PWD:/repo" \
            ghcr.io/gitleaks/gitleaks:v8.30.1 \
            git --redact --report-format json --report-path /repo/gitleaks-report.json /repo

      - name: Upload the report
        if: always()
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
        with:
          name: secret-scan-report
          path: gitleaks-report.json
          if-no-files-found: ignore
          retention-days: 30
