name: PR Review (Qodo)

on:
  pull_request_target:
    types: [opened, synchronize, reopened, ready_for_review]
  issue_comment:

jobs:
  pr_review:
    if: ${{ github.event.sender.type != 'Bot' }}
    runs-on: ubuntu-24.04
    permissions:
      issues: write
      pull-requests: write
      contents: write
    steps:
      # Checkout required so PR-Agent reads .pr_agent.toml from repo root.
      # All review rules, custom labels, ignore patterns, and tool configs
      # live in .pr_agent.toml — no inline extra_instructions needed here.
      - name: Checkout
        uses: actions/checkout@v4

      - name: PR Agent
        uses: qodo-ai/pr-agent@main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_KEY: ${{ secrets.DOUBAO_API_KEY }}
          OPENAI.API_BASE: "https://ark.cn-beijing.volces.com/api/coding/v3"
          config.model: "ark-code-latest"
          github_action_config.auto_review: "true"
          github_action_config.auto_describe: "true"
          github_action_config.auto_improve: "true"
