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
| 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 | # Required to mint the OIDC token exchanged for a Claude API access token (Workload Identity Federation) |
| 21 | id-token: write |
| 22 | |
| 23 | steps: |
| 24 | - name: Checkout repository |
| 25 | uses: actions/checkout@v4 |
| 26 | |
| 27 | - name: Run Claude Code slash command |
| 28 | uses: anthropics/claude-code-action@v1 |
| 29 | env: |
| 30 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 31 | CLAUDE_CODE_SCRIPT_CAPS: '{"comment-on-duplicates.sh":1}' |
| 32 | with: |
| 33 | github_token: ${{ secrets.GITHUB_TOKEN }} |
| 34 | allowed_non_write_users: "*" |
| 35 | prompt: "/dedupe ${{ github.repository }}/issues/${{ github.event.issue.number || inputs.issue_number }}" |
| 36 | # Authenticate to the Claude API via Workload Identity Federation |
| 37 | # (the workflow's OIDC token is exchanged for a short-lived access |
| 38 | # token) instead of a static API key. |
| 39 | anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }} |
| 40 | anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }} |
| 41 | anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }} |
| 42 | anthropic_workspace_id: ${{ vars.ANTHROPIC_WORKSPACE_ID }} |
| 43 | claude_args: "--model claude-sonnet-4-5-20250929" |
| 44 | |
| 45 | - name: Log duplicate comment event to Statsig |
| 46 | if: always() |
| 47 | env: |
| 48 | STATSIG_API_KEY: ${{ secrets.STATSIG_API_KEY }} |
| 49 | ISSUE_NUMBER: ${{ github.event.issue.number || inputs.issue_number }} |
| 50 | REPO: ${{ github.repository }} |
| 51 | TRIGGERED_BY: ${{ github.event_name }} |
| 52 | WORKFLOW_RUN_ID: ${{ github.run_id }} |
| 53 | run: | |
| 54 | if [ -z "$STATSIG_API_KEY" ]; then |
| 55 | echo "STATSIG_API_KEY not found, skipping Statsig logging" |
| 56 | exit 0 |
| 57 | fi |
| 58 | |
| 59 | # Prepare the event payload |
| 60 | EVENT_PAYLOAD=$(jq -n \ |
| 61 | --arg issue_number "$ISSUE_NUMBER" \ |
| 62 | --arg repo "$REPO" \ |
| 63 | --arg triggered_by "$TRIGGERED_BY" \ |
| 64 | --arg workflow_run_id "$WORKFLOW_RUN_ID" \ |
| 65 | '{ |
| 66 | events: [{ |
| 67 | eventName: "github_duplicate_comment_added", |
| 68 | value: 1, |
| 69 | metadata: { |
| 70 | repository: $repo, |
| 71 | issue_number: ($issue_number | tonumber), |
| 72 | triggered_by: $triggered_by, |
| 73 | workflow_run_id: $workflow_run_id |
| 74 | }, |
| 75 | time: (now | floor | tostring) |
| 76 | }] |
| 77 | }') |
| 78 | |
| 79 | # Send to Statsig API |
| 80 | echo "Logging duplicate comment event to Statsig for issue #${ISSUE_NUMBER}" |
| 81 | |
| 82 | RESPONSE=$(curl -s -w "\n%{http_code}" -X POST https://events.statsigapi.net/v1/log_event \ |
| 83 | -H "Content-Type: application/json" \ |
| 84 | -H "STATSIG-API-KEY: ${STATSIG_API_KEY}" \ |
| 85 | -d "$EVENT_PAYLOAD") |
| 86 | |
| 87 | HTTP_CODE=$(echo "$RESPONSE" | tail -n1) |
| 88 | BODY=$(echo "$RESPONSE" | head -n-1) |
| 89 | |
| 90 | if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 202 ]; then |
| 91 | echo "Successfully logged duplicate comment event for issue #${ISSUE_NUMBER}" |
| 92 | else |
| 93 | echo "Failed to log duplicate comment event for issue #${ISSUE_NUMBER}. HTTP ${HTTP_CODE}: ${BODY}" |
| 94 | fi |