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
82 lines · 2.8 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 id-token: write
21
22 steps:
23 - name: Checkout repository
24 uses: actions/checkout@v4
25
26 - name: Run Claude Code slash command
27 uses: anthropics/claude-code-action@v1
28 env:
29 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 with:
31 prompt: "/dedupe ${{ github.repository }}/issues/${{ github.event.issue.number || inputs.issue_number }}"
32 anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
33 claude_args: "--model claude-sonnet-4-5-20250929"
34
35 - name: Log duplicate comment event to Statsig
36 if: always()
37 env:
38 STATSIG_API_KEY: ${{ secrets.STATSIG_API_KEY }}
39 run: |
40 ISSUE_NUMBER=${{ github.event.issue.number || inputs.issue_number }}
41 REPO=${{ github.repository }}
42
43 if [ -z "$STATSIG_API_KEY" ]; then
44 echo "STATSIG_API_KEY not found, skipping Statsig logging"
45 exit 0
46 fi
47
48 # Prepare the event payload
49 EVENT_PAYLOAD=$(jq -n \
50 --arg issue_number "$ISSUE_NUMBER" \
51 --arg repo "$REPO" \
52 --arg triggered_by "${{ github.event_name }}" \
53 '{
54 events: [{
55 eventName: "github_duplicate_comment_added",
56 value: 1,
57 metadata: {
58 repository: $repo,
59 issue_number: ($issue_number | tonumber),
60 triggered_by: $triggered_by,
61 workflow_run_id: "${{ github.run_id }}"
62 },
63 time: (now | floor | tostring)
64 }]
65 }')
66
67 # Send to Statsig API
68 echo "Logging duplicate comment event to Statsig for issue #${ISSUE_NUMBER}"
69
70 RESPONSE=$(curl -s -w "\n%{http_code}" -X POST https://events.statsigapi.net/v1/log_event \
71 -H "Content-Type: application/json" \
72 -H "STATSIG-API-KEY: ${STATSIG_API_KEY}" \
73 -d "$EVENT_PAYLOAD")
74
75 HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
76 BODY=$(echo "$RESPONSE" | head -n-1)
77
78 if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 202 ]; then
79 echo "Successfully logged duplicate comment event for issue #${ISSUE_NUMBER}"
80 else
81 echo "Failed to log duplicate comment event for issue #${ISSUE_NUMBER}. HTTP ${HTTP_CODE}: ${BODY}"
82 fi