name: Secret Scan

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

# Minimal permissions: secretlint only needs to read repository contents.
# The workflow does not comment on PRs, upload artifacts, or modify state.
permissions:
  contents: read

jobs:
  secretlint:
    name: secretlint
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          # Full history lets secretlint see any new files introduced in a PR
          fetch-depth: 0

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      - name: Install dependencies
        run: npm ci --ignore-scripts

      - name: Run secretlint
        # Scan everything except what .secretlintignore excludes. The pre-commit
        # hook only scans staged files (fast); this CI job is the authoritative
        # check that catches anything that slipped through --no-verify.
        run: npx secretlint --maskSecrets "**/*" "**/.*"
