name: Claude Issue Triage
on:
  issues:
    types: [opened]
  issue_comment:
    types: [created]

jobs:
  triage-issue:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    if: >-
      github.event_name == 'issues' ||
      (github.event_name == 'issue_comment' && !github.event.issue.pull_request && github.event.comment.user.type != 'Bot')
    concurrency:
      group: issue-triage-${{ github.event.issue.number }}
      cancel-in-progress: true
    permissions:
      contents: read
      issues: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Run Claude Code for Issue Triage
        timeout-minutes: 5
        uses: anthropics/claude-code-action@v1
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GH_REPO: ${{ github.repository }}
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          allowed_non_write_users: "*"
          prompt: "/triage-issue REPO: ${{ github.repository }} ISSUE_NUMBER: ${{ github.event.issue.number }} EVENT: ${{ github.event_name }}"
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          claude_args: |
            --model claude-opus-4-6
