robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1name : "label-pr" 2on : 3pull_request_target : 4types : [ opened , synchronize , reopened , ready_for_review ] 5 6permissions : {} 7 8jobs : 9label : 10if : github.event.action == 'opened' 11runs-on : ubuntu-latest 12permissions : 13contents : read 14pull-requests : write 15steps : 16- uses : actions/checkout@v7.0.1 17with : 18persist-credentials : false 19 20- name : "changed-files" 21uses : actions/labeler@v7.0.0 22with : 23configuration-path : .github/scripts/labeler_configuration.yml 24 25# Scope GITHUB_TOKEN to this step only, avoid exposing to 3P `actions/labeler`. 26- name : "guess type/scope from title" 27env : 28GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 29GH_REPO : ${{ github.repository }} 30PR_NUMBER : ${{ github.event.pull_request.number }} 31PR_TITLE : ${{ github.event.pull_request.title }} 32run : | 33gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|([[:alpha:]]+)(\(.*\))?!?:.*|\1|')" || true 34gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')" || true 35gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+(\(.*\))?!:.*|breaking-change|')" || true 36 37- name : "target:release" 38if : startsWith(github.base_ref, 'release') 39uses : actions/github-script@v9 40with : 41script : | 42github.rest.issues.addLabels({ 43issue_number: context.issue.number, 44owner: context.repo.owner, 45repo: context.repo.repo, 46labels: ['target:release'] 47}) 48 49no-ai-advertisements : 50runs-on : ubuntu-latest 51permissions : 52# Least privilege. 53pull-requests : read 54env : 55GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 56GH_REPO : ${{ github.repository }} 57PR_NUMBER : ${{ github.event.pull_request.number }} 58steps : 59# AGENTS.md: disclose with a bare "AI-assisted" trailer, and do not name the model or service. 60- name : "Reject AI advertisements in commit messages" 61shell : bash 62run : | 63set -euo pipefail 64 65# Prefix each message line with its commit, so a failure names the offender. 66commits=$(gh api "repos/$GH_REPO/pulls/$PR_NUMBER/commits" --paginate \ 67--jq '.[] | .sha[0:12] as $sha | .commit.message | split("\n")[] | "\($sha) \(.)"') 68 69tools='aider|anthropic|chatgpt|claude|cline|codex|copilot|cursor|devin|gemini|openai|opencode|windsurf|\bamp\b|\bai\b|\bllm\b|\bgpt\b' 70by='(co-authored|signed-off|assisted|helped|generated|written|created|reviewed|suggested|reported|tested|debugged)[ -]?by' 71hosts='claude\.ai|anthropic\.com|openai\.com|chatgpt\.com|copilot\.microsoft\.com|cursor\.(com|sh)|ampcode\.com|codeium\.com|windsurf\.com|(gemini|aistudio)\.google\.com' 72 73found=$({ 74# Attribution trailers and phrasing. 75grep -Ei "^\S+ +$by:.*($tools)" <<< "$commits" || true 76grep -Ei "(generated|written|assisted|supported|powered|created|helped)[ -](by|with)[: ]+.*($tools)" <<< "$commits" || true 77# Session links and trailers. 78grep -Ei "^\S+ +($tools)[a-z0-9-]*-(session|thread|chat|conversation|link|url|id):" <<< "$commits" || true 79grep -Ei "https?://[^ ]*($hosts)" <<< "$commits" || true 80grep -Ei '@(anthropic|openai)\.com' <<< "$commits" || true 81# Tool names anywhere, not just as attribution. Disabled to avoid false positives, for now... 82# grep -Ei 'aider|anthropic|chatgpt|claude|codex|copilot|devin|gemini|openai|opencode|windsurf' <<< "$commits" || true 83# The "AI-assisted" trailer must not name the tool. 84grep -Ei '^\S+ +AI-assisted:.*\S' <<< "$commits" || true 85grep -F '🤖' <<< "$commits" || true 86} | sort -u) 87 88if [[ -n "$found" ]]; then 89echo 'Remove AI advertisements from commit messages ("Co-authored-by: Claude", etc.).' 90echo 'Only a generic "AI-assisted" token is allowed, see AGENTS.md.' 91echo 92echo "$found" 93exit 1 94fi 95 96request-reviewer : 97if : github.event.action == 'opened' 98needs : label 99permissions : 100pull-requests : write 101uses : ./.github/workflows/reviewers_add.yml