Skip to content

Copilot 自动代码审查支持三个粒度:个人开关、仓库 Ruleset、组织 Ruleset。通过 Branch Ruleset 可以配置在 PR 创建时自动触发、新 Push 时重新触发、草稿 PR 也触发。2026 年 6 月起,审查运行将消耗 GitHub Actions 分钟数。

GitHub Copilot 自动代码审查配置:个人、仓库和组织三级设置

个人开启自动审查(Pro / Pro+)

适用于个人开发者,对自己参与的 PR 自动触发 Copilot Review:

  1. 点击右上角头像 → Your ProfileCopilot settings
  2. 开启 Automatic Copilot code review

开启后,你打开或参与的 PR 会自动触发 Copilot 审查,无需每次手动请求。

仓库级自动审查(Repository Ruleset)

为单个仓库配置,精细控制哪些分支上的 PR 触发审查:

  1. 进入仓库 SettingsRulesRulesets
  2. 点击 New branch ruleset
  3. Branch rules 中勾选 Automatically request Copilot code review
  4. 可选项:
    • Review on new pushes:PR 有新 Push 时重新触发审查
    • Review draft pull requests:草稿 PR 也触发审查(默认关闭)

建议至少配置 Target branches 为 mainmaster,避免对所有功能分支都触发审查(消耗额度)。

组织级自动审查(Organization Ruleset)

统一为组织内的仓库配置审查策略,适合团队统一管理代码质量标准:

  1. 进入组织 SettingsRepositoryRulesets
  2. 创建新的 Branch Ruleset
  3. 设置 Repository targeting(包含/排除哪些仓库)
  4. 设置 Branch targeting(目标分支)
  5. Branch rules 中勾选 Automatically request Copilot code review

组织级 Ruleset 会覆盖符合条件的仓库,成员打开 PR 时自动触发审查,无需每个仓库单独配置。

Runner 配置

默认使用 GitHub 托管 Runner(Ubuntu x64)。如需自定义 Runner:

支持的 Runner 类型

  • ARC 管理的自托管 Runner(官方支持)
  • GitHub 更大规格的托管 Runner(更快但费用更高)

防火墙配置(自托管 Runner 必须放行):

  • api.githubcopilot.com
  • uploads.github.com
  • user-images.githubusercontent.com

copilot-setup-steps.yml 中指定 Runner

yaml
jobs:
  copilot-setup-steps:
    runs-on: [self-hosted, ubuntu-latest]
    steps:
      - name: 检出代码
        uses: actions/checkout@v4

费用说明

2026 年 6 月 1 日起,每次 Copilot 代码审查运行会消耗 GitHub Actions 分钟数:

  • GitHub 托管的标准 Runner:按标准分钟费率计费
  • 更大规格 Runner:更高的每分钟费率
  • 自托管 Runner:不消耗 GitHub Actions 分钟,但需要自行运维 Runner

建议在启用自动审查之前,评估团队的 PR 频率和 Actions 额度是否充足。

组合使用建议

场景推荐配置
个人项目个人开关即可
单团队项目仓库级 Ruleset,Target main 分支
多仓库团队组织级 Ruleset,统一策略
严格审查开启"Review on new pushes"
节省额度关闭草稿 PR 触发

常见问题

Q: 如何关闭某个仓库的自动审查?

A: 进入该仓库的 Settings → Rules → Rulesets,找到对应的 Ruleset,取消勾选"Automatically request Copilot code review"。

Q: 组织 Ruleset 和仓库 Ruleset 有冲突时,哪个生效?

A: 两者叠加生效,都会触发审查。如果不想重复触发,需要在组织 Ruleset 的 Repository targeting 中排除已单独配置的仓库。

Q: 审查结果可以设置为 PR 合并的必要条件吗?

A: 目前不支持。Copilot Review 是"仅评论"模式,不能设置为 Required Review。合并门控仍需人工 Reviewer。