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