forked from scylladb/argus
-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (55 loc) · 2.35 KB
/
Copy pathai-assisted-label.yaml
File metadata and controls
64 lines (55 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Add ai-assisted label
on:
pull_request_target:
types: [opened, synchronize]
jobs:
detect-ai:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Ensure ai-assisted label exists
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
run: |
gh label create "ai-assisted" --repo "$REPO" --color "8B5CF6" --description "AI-assisted contribution" 2>/dev/null || true
- name: Check for AI assistance markers
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
found=false
# Check PR description for Claude Code marker
pr_body=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json body --jq '.body // ""')
if echo "$pr_body" | grep -qi "Generated with.*Claude Code"; then
echo "Found: Claude Code marker in PR description"
found=true
fi
# Check commit messages for AI co-authors
if [ "$found" = false ]; then
commits=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json commits --jq '.commits[].messageBody')
if echo "$commits" | grep -qi "noreply@anthropic\.com"; then
echo "Found: Anthropic co-author in commit trailers"
found=true
fi
if echo "$commits" | grep -qi "copilot.*@users\.noreply\.github\.com\|copilot-swe-agent"; then
echo "Found: GitHub Copilot co-author in commit trailers"
found=true
fi
fi
# Check if PR author is a known AI bot
pr_author=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json author --jq '.author.login')
pr_author_lower=$(echo "$pr_author" | tr '[:upper:]' '[:lower:]')
if [[ "$pr_author_lower" == *"copilot"* ]] || [[ "$pr_author_lower" == *"claude"* ]]; then
echo "Found: PR authored by AI bot ($pr_author)"
found=true
fi
# Add label if any marker found (idempotent)
if [ "$found" = true ]; then
echo "Adding 'ai-assisted' label to PR #$PR_NUMBER"
gh pr edit "$PR_NUMBER" --repo "$REPO" --add-label "ai-assisted"
else
echo "No AI assistance markers detected in PR #$PR_NUMBER"
fi