Repository navigation
ci: add no-ai-lines check #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Fails when a pull request or a push to main carries an AI session link, | ||
| # an AI co-author line or a "generated with" line, in the PR title, the PR | ||
| # body or any commit message. A pull request with more than 250 commits | ||
| # fails, because the API lists at most 250 and the rest cannot be checked. | ||
| name: no-ai-lines | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, edited, synchronize, reopened] | ||
| push: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| check: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check for AI lines | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| REPO: ${{ github.repository }} | ||
| EVENT_NAME: ${{ github.event_name }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| run: | | ||
| set -euo pipefail | ||
| banned='claude-session:|claude\.ai/code|co-authored-by:.*(claude|anthropic|copilot|cursor|grok|gemini|openai|codex|chatgpt|gpt|aider|devin|windsurf|deepseek|qwen|kimi)|generated (with|by) .*(claude|ai\b)|🤖' | ||
| fail=0 | ||
| check() { | ||
| if grep -qiE "$banned" <<< "$2"; then | ||
| echo "::error::AI line found in $1" | ||
| echo "Matched in $1:" | ||
| grep -iE "$banned" <<< "$2" | sed 's/^/ /' | ||
| fail=1 | ||
| fi | ||
| } | ||
| if [ "$EVENT_NAME" = pull_request ]; then | ||
| total=$(jq -r '.pull_request.commits // 0' "$GITHUB_EVENT_PATH") | ||
| if [ "$total" -gt 250 ]; then | ||
| echo "::error::This pull request has $total commits. The API lists at most 250, so the commits could not all be checked." | ||
| exit 1 | ||
| fi | ||
| check "PR title" "$(jq -r '.pull_request.title // ""' "$GITHUB_EVENT_PATH")" | ||
| check "PR body" "$(jq -r '.pull_request.body // ""' "$GITHUB_EVENT_PATH")" | ||
| gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/commits" \ | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| --jq '.[] | [.sha, (.commit.message | @base64)] | @tsv' > commits.tsv | ||
| while IFS=$'\t' read -r sha msg; do | ||
| check "commit $sha" "$(printf '%s' "$msg" | base64 -d)" | ||
| done < commits.tsv | ||
| else | ||
| jq -r '.commits[] | [.id, (.message | @base64)] | @tsv' "$GITHUB_EVENT_PATH" > commits.tsv | ||
| while IFS=$'\t' read -r sha msg; do | ||
| check "commit $sha" "$(printf '%s' "$msg" | base64 -d)" | ||
| done < commits.tsv | ||
| fi | ||
| if [ "$fail" -ne 0 ]; then | ||
| echo "Fix: remove the AI lines. Edit the PR title or body, or rewrite the commit message (git commit --amend, or git rebase -r with reword) and force-push the branch." | ||
| exit 1 | ||
| fi | ||
| echo "No AI lines found." | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not match human co-authors by name substring.
Co-authored-by: Devin Smith <devin@example.com>matchesdevin, even when the co-author is a person. The check then fails and asks the contributor to remove a valid attribution. Match distinguishable AI identities instead of arbitrary name substrings.Match ChatGPT session links.
A
chatgpt.com/share/<id>link identifies a shared ChatGPT conversation, but this pattern accepts it. (help.openai.com) Add the supported session-link formats to the pattern.