PureYAML/.github/workflows/no-cursor-attribution.yml
Mihaela Mihaljevic 28cfd3839d chore(hooks): block Cursor attribution locally and in CI
Reject Cursor co-author trailers, cursor.com agent emails, and machine
attribution tells in commit messages and staged content, plus a Cursor
author or committer identity. Add a workflow enforcing the same rule
server-side on push and pull request.
2026-06-07 09:43:29 +02:00

61 lines
2.2 KiB
YAML

name: No Cursor attribution
# Server-side companion to the local .githooks/commit-msg and pre-commit guards.
# Fails the check if any commit pushed (or in a PR) carries Cursor attribution:
# a Cursor co-author trailer, an @cursor.com email, or a "generated with Cursor"
# tell, in the commit message or in the author/committer identity.
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
scan:
name: Scan commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Reject Cursor attribution
env:
EVENT: ${{ github.event_name }}
PR_BASE: ${{ github.event.pull_request.base.sha }}
PR_HEAD: ${{ github.event.pull_request.head.sha }}
PUSH_BEFORE: ${{ github.event.before }}
SHA: ${{ github.sha }}
run: |
set -euo pipefail
# Resolve the set of commits to scan.
if [ "$EVENT" = "pull_request" ]; then
range="${PR_BASE}..${PR_HEAD}"
elif [ -n "${PUSH_BEFORE:-}" ] && [ "$PUSH_BEFORE" != "0000000000000000000000000000000000000000" ]; then
range="${PUSH_BEFORE}..${SHA}"
else
# New branch / tag push or manual run: scan just the tip commit.
range="${SHA}~1..${SHA}"
git rev-parse "${SHA}~1" >/dev/null 2>&1 || range="$SHA"
fi
echo "Scanning commit range: $range"
# Emit message + author + committer for each commit, then grep.
fmt='commit %H%nauthor: %an <%ae>%ncommitter: %cn <%ce>%n%B'
if printf '%s' "$range" | grep -q '\.\.'; then
log=$(git log --format="$fmt" "$range")
else
log=$(git log -1 --format="$fmt" "$range")
fi
pattern='cursoragent@cursor\.com|@cursor\.com|Co-authored-by:[[:space:]]*Cursor|Generated (with|by) Cursor|with help from Cursor|Powered by Cursor'
if printf '%s\n' "$log" | grep -niE -- "$pattern"; then
echo "::error::Cursor attribution found in the commits above. Strip it (rewrite the commits) before pushing."
exit 1
fi
echo "No Cursor attribution found."