queue_rules:
  - name: default
    conditions:
      - check-success=CI
      - check-success=Commit Lint

pull_request_rules:
  # 自动合并 Dependabot 的更新
  - name: 自动合并 Dependabot 更新
    conditions:
      - author=dependabot[bot]
      - check-success=CI
      - check-success=Commit Lint
    actions:
      review:
        type: APPROVE
        message: 自动批准 Dependabot 更新
      queue:
        name: default

  # 自动合并有 'automerge' 标签且测试通过的 PR
  - name: 自动合并标记的 PR
    conditions:
      - label=automerge
      - check-success=CI
      - check-success=Commit Lint
      - "#approved-reviews-by>=1"
      - "#changes-requested-reviews-by=0"
    actions:
      queue:
        name: default

  # 自动给小 PR 添加标签（根据文件数）
  - name: 标记小 PR 方便快速 Review
    conditions:
      - "#files<=3"
    actions:
      label:
        add:
          - quick-review

  # 提醒大 PR 需要拆分（根据文件数）
  - name: 提醒大 PR
    conditions:
      - "#files>=20"
    actions:
      comment:
        message: |
          ⚠️ 这个 PR 改动了较多文件（20+ 个），建议拆分成多个小 PR，便于 Review 和测试。

          ⚠️ This PR modifies many files (20+). Consider splitting it into smaller PRs for easier review and testing.

  # 自动更新过期的分支
  - name: 自动更新过期分支
    conditions:
      - -draft
      - -closed
      - base=master
      - "#approved-reviews-by>=1"
    actions:
      update: {}

  # 自动添加标签
  - name: 添加 dependencies 标签
    conditions:
      - author=dependabot[bot]
    actions:
      label:
        add:
          - dependencies

  # 标记需要关注的 PR
  - name: 标记需要更新的 PR
    conditions:
      - "#commits-behind>10"
    actions:
      label:
        add:
          - needs-rebase
