name: Orca Issue Dedupe description: Automatically dedupe GitHub issues using AI on: issues: types: [opened] workflow_dispatch: inputs: issue_number: description: 'Issue number to process for duplicate detection' required: true type: string jobs: dedupe-issues: runs-on: ubuntu-latest timeout-minutes: 30 permissions: contents: read issues: write steps: - name: Checkout repository uses: actions/checkout@v7 - name: Run Claude Code slash command uses: anthropics/claude-code-action@v1 env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CLAUDE_CODE_SCRIPT_CAPS: '{"comment-on-duplicates.sh":1}' # The action stops at Claude's first result, so a turn that ends while a background agent # still works would drop the rest of the dedupe; keep agents in the foreground. CLAUDE_CODE_DISABLE_BACKGROUND_TASKS: "1" with: github_token: ${{ secrets.GITHUB_TOKEN }} # Issues are opened by users without write access; the job's permissions and the # allowed-tools list in .claude/commands/dedupe.md keep what Claude can do narrow. allowed_non_write_users: "*" # The backfill workflow dispatches this one with GITHUB_TOKEN, so those runs come from github-actions[bot] allowed_bots: "github-actions" prompt: "/dedupe ${{ github.repository }}/issues/${{ github.event.issue.number || inputs.issue_number }}" claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} # The allowed-tools in .claude/commands/dedupe.md cover only the command's own turn, not the # agents it starts, so the same two scripts are allowed for the whole session here. claude_args: '--model claude-haiku-5-5 --allowedTools "Bash(./scripts/gh.sh:*),Bash(./scripts/comment-on-duplicates.sh:*)" --disallowedTools "WebFetch,WebSearch,Write,Edit,MultiEdit,NotebookEdit"' - name: Log duplicate comment event to Statsig if: always() env: STATSIG_API_KEY: ${{ secrets.STATSIG_API_KEY }} ISSUE_NUMBER: ${{ github.event.issue.number || inputs.issue_number }} REPO: ${{ github.repository }} TRIGGERED_BY: ${{ github.event_name }} WORKFLOW_RUN_ID: ${{ github.run_id }} run: | if [ -z "$STATSIG_API_KEY" ]; then echo "STATSIG_API_KEY not found, skipping Statsig logging" exit 0 fi # Prepare the event payload EVENT_PAYLOAD=$(jq -n \ --arg issue_number "$ISSUE_NUMBER" \ --arg repo "$REPO" \ --arg triggered_by "$TRIGGERED_BY" \ --arg workflow_run_id "$WORKFLOW_RUN_ID" \ '{ events: [{ eventName: "github_duplicate_comment_added", value: 1, metadata: { repository: $repo, issue_number: ($issue_number | tonumber), triggered_by: $triggered_by, workflow_run_id: $workflow_run_id }, time: (now | floor | tostring) }] }') # Send to Statsig API echo "Logging duplicate comment event to Statsig for issue #${ISSUE_NUMBER}" RESPONSE=$(curl -s -w "\n%{http_code}" -X POST https://events.statsigapi.net/v1/log_event \ -H "Content-Type: application/json" \ -H "STATSIG-API-KEY: ${STATSIG_API_KEY}" \ -d "$EVENT_PAYLOAD") HTTP_CODE=$(echo "$RESPONSE" | tail -n1) BODY=$(echo "$RESPONSE" | head -n-1) if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 202 ]; then echo "Successfully logged duplicate comment event for issue #${ISSUE_NUMBER}" else echo "Failed to log duplicate comment event for issue #${ISSUE_NUMBER}. HTTP ${HTTP_CODE}: ${BODY}" fi