spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / .github / workflows / claude-dedupe-issues.yml
86 lines · 3.1 KBRaw
1name: Claude Issue Dedupe
2description: Automatically dedupe GitHub issues using Claude Code
3on:
4 issues:
5 types: [opened]
6 workflow_dispatch:
7 inputs:
8 issue_number:
9 description: 'Issue number to process for duplicate detection'
10 required: true
11 type: string
12
13jobs:
14 claude-dedupe-issues:
15 runs-on: ubuntu-latest
16 timeout-minutes: 10
17 permissions:
18 contents: read
19 issues: write
20
21 steps:
22 - name: Checkout repository
23 uses: actions/checkout@v4
24
25 - name: Run Claude Code slash command
26 uses: anthropics/claude-code-action@v1
27 env:
28 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 CLAUDE_CODE_SCRIPT_CAPS: '{"comment-on-duplicates.sh":1}'
30 with:
31 github_token: ${{ secrets.GITHUB_TOKEN }}
32 allowed_non_write_users: "*"
33 prompt: "/dedupe ${{ github.repository }}/issues/${{ github.event.issue.number || inputs.issue_number }}"
34 anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
35 claude_args: "--model claude-sonnet-4-5-20250929"
36
37 - name: Log duplicate comment event to Statsig
38 if: always()
39 env:
40 STATSIG_API_KEY: ${{ secrets.STATSIG_API_KEY }}
41 ISSUE_NUMBER: ${{ github.event.issue.number || inputs.issue_number }}
42 REPO: ${{ github.repository }}
43 TRIGGERED_BY: ${{ github.event_name }}
44 WORKFLOW_RUN_ID: ${{ github.run_id }}
45 run: |
46 if [ -z "$STATSIG_API_KEY" ]; then
47 echo "STATSIG_API_KEY not found, skipping Statsig logging"
48 exit 0
49 fi
50
51 # Prepare the event payload
52 EVENT_PAYLOAD=$(jq -n \
53 --arg issue_number "$ISSUE_NUMBER" \
54 --arg repo "$REPO" \
55 --arg triggered_by "$TRIGGERED_BY" \
56 --arg workflow_run_id "$WORKFLOW_RUN_ID" \
57 '{
58 events: [{
59 eventName: "github_duplicate_comment_added",
60 value: 1,
61 metadata: {
62 repository: $repo,
63 issue_number: ($issue_number | tonumber),
64 triggered_by: $triggered_by,
65 workflow_run_id: $workflow_run_id
66 },
67 time: (now | floor | tostring)
68 }]
69 }')
70
71 # Send to Statsig API
72 echo "Logging duplicate comment event to Statsig for issue #${ISSUE_NUMBER}"
73
74 RESPONSE=$(curl -s -w "\n%{http_code}" -X POST https://events.statsigapi.net/v1/log_event \
75 -H "Content-Type: application/json" \
76 -H "STATSIG-API-KEY: ${STATSIG_API_KEY}" \
77 -d "$EVENT_PAYLOAD")
78
79 HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
80 BODY=$(echo "$RESPONSE" | head -n-1)
81
82 if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 202 ]; then
83 echo "Successfully logged duplicate comment event for issue #${ISSUE_NUMBER}"
84 else
85 echo "Failed to log duplicate comment event for issue #${ISSUE_NUMBER}. HTTP ${HTTP_CODE}: ${BODY}"
86 fi