Files
JimsGarage/.github/workflows/lint.yml
cyberops7 d5dadb5f4b ci: lint and secret-scan pull requests
Add a GitHub Actions workflow that runs the project's pre-commit hooks
against the files changed in each PR, plus a gitleaks secret scan over
the PR's commits. Both block on findings.

Enrich the existing .pre-commit-config.yaml with general hygiene checks
and four linters (shellcheck, yamllint, actionlint, gitleaks), add a
lenient yamllint config tuned for the repo's existing YAML, and add a
gitleaks config that keeps the full default ruleset while baselining the
repo's pre-existing intentional dummy credentials.

Linting is scoped to changed files, so the checks pass on the current
tree and only hold new or edited files to standard.

- .github/workflows/lint.yml: pull_request workflow, read-only token,
  two jobs (pre-commit on changed files + gitleaks on the commit range)
- .pre-commit-config.yaml: keep existing hooks; add hygiene checks,
  shellcheck (--severity=warning), yamllint, actionlint, gitleaks
- .yamllint.yaml: lenient ruleset
- .gitleaks.toml: default rules + allowlist for .env/example placeholders
- .gitleaksignore: baseline of pre-existing intentional dummy credentials
2026-07-05 14:33:50 -06:00

57 lines
1.7 KiB
YAML

---
name: Lint
on:
pull_request:
# Read-only: this workflow only inspects code and reports status, so it works
# from fork PRs (which receive a read-only token and no secrets).
permissions:
contents: read
concurrency:
group: lint-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
pre-commit:
name: pre-commit (changed files)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Run pre-commit on changed files
# gitleaks is handled by the dedicated job below (it scans git history,
# not a file list), so skip it here to avoid a redundant no-op run.
env:
SKIP: gitleaks
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
python -m pip install --upgrade pre-commit
pre-commit run \
--from-ref "$BASE_SHA" \
--to-ref "$HEAD_SHA" \
--show-diff-on-failure
gitleaks:
name: gitleaks (secret scan)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Scan PR commits for secrets
env:
GITLEAKS_VERSION: 8.30.1
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
curl -sSfL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
| tar -xz gitleaks
./gitleaks git . --redact --no-banner --log-opts="${BASE_SHA}..${HEAD_SHA}"