mnswpr/.github/workflows/checks.yml
ayo 0a3571e2f4
chore: add contribution content checks (#53)
Adds scripts/check-content.mjs, a zero-dependency scanner for commits, branch
names, PR text, and contributed lines. It checks structural rules (attribution
trailers and footers, session links) and a maintainer-managed reserved-terms
list, shipped as salted digests in .repo-policy.json. Findings report a location
and a masked preview, never the matched term.

Wired up opt-in: the pre-commit hook scans the staged diff and branch name, a new
commit-msg hook scans the message, and the Checks workflow gates PRs and pushes
to main. The digest list ships empty; structural checks run regardless.
2026-07-16 21:17:44 +02:00

94 lines
2.6 KiB
YAML

name: Checks
on:
pull_request:
push:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- name: Set node
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- name: Set node
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm test
content:
runs-on: ubuntu-latest
steps:
# Full history: the scan walks a commit range.
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set node
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
# No install — the scanner has no dependencies.
- name: Scan the pull request range
if: github.event_name == 'pull_request'
env:
BASE_REF: ${{ github.base_ref }}
run: |
git fetch --no-tags --quiet origin "$BASE_REF"
node scripts/check-content.mjs --range "origin/$BASE_REF...HEAD"
# Title and body reach the script as files, never as inline shell.
- name: Scan the pull request title and body
if: github.event_name == 'pull_request'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
run: |
printf '%s\n' "$PR_TITLE" > "$RUNNER_TEMP/pr-title.txt"
printf '%s\n' "$PR_BODY" > "$RUNNER_TEMP/pr-body.txt"
node scripts/check-content.mjs --text "$RUNNER_TEMP/pr-title.txt" --text "$RUNNER_TEMP/pr-body.txt"
- name: Scan the head branch name
if: github.event_name == 'pull_request'
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: node scripts/check-content.mjs --branch "$HEAD_REF"
- name: Scan the pushed range
if: github.event_name == 'push'
env:
PUSH_BEFORE: ${{ github.event.before }}
PUSH_AFTER: ${{ github.sha }}
run: |
# A new branch or a force-push can leave `before` unreachable.
before="$PUSH_BEFORE"
if ! git rev-parse --quiet --verify "$before^{commit}" > /dev/null; then
before="$(git rev-parse "$PUSH_AFTER~1")"
fi
node scripts/check-content.mjs --range "$before..$PUSH_AFTER"