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