name: Fast Claude

on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]
  issues:
    types: [opened, assigned]
  pull_request_review:
    types: [submitted]

jobs:
  check-membership:
    if: |
      (github.event_name == 'issue_comment' && contains(github.event.comment.body, '/ai-fast')) ||
      (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '/ai-fast')) ||
      (github.event_name == 'pull_request_review' && contains(github.event.review.body, '/ai-fast')) ||
      (github.event_name == 'issues' && contains(github.event.issue.body, '/ai-fast'))
    uses: ./.github/workflows/check-org-membership.yml
    secrets:
      access_token: ${{ secrets.ORG_ACCESS_TOKEN }}

  claude-code-action:
    needs: check-membership
    if: |
      needs.check-membership.outputs.is_member == 'true'
    runs-on: ubicloud-standard-8
    permissions:
      contents: write
      pull-requests: write
      issues: write
      id-token: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Run Claude PR Action
        uses: anthropics/claude-code-action@v1
        with:
          claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
          allowed_bots: "windmill-internal-app[bot]"
          trigger_phrase: "/ai-fast"
          settings: |
            {
              "env": {
                "SQLX_OFFLINE": "true"
              }
            }
          claude_args: |
            --allowedTools "Bash,WebFetch,WebSearch"
            --model opus
