Skip to content

Conversation

@JiayangZhou
Copy link

@JiayangZhou JiayangZhou commented Dec 4, 2025

This change adds support for GitHub's Copilot code review feature in repository rulesets, allowing automatic code review requests for pull requests.

Changes:

  • Add copilot_code_review rule to repository ruleset schema
  • Add CopilotCodeReviewRuleParameters and related types to go-github
  • Implement expand/flatten logic for copilot_code_review rules

The copilot_code_review rule supports two configuration options:

  • review_new_pushes: Automatically review each new push to the PR
  • review_draft_pull_requests: Automatically review draft PRs

Both options default to false, matching GitHub UI behavior.

Resolves #2694 and #2583


Before the change?

The github_repository_ruleset resource did not support GitHub's Copilot code review feature
Users could not configure automatic Copilot code review requests through Terraform
Rulesets created in the GitHub UI with Copilot code review enabled would cause drift or errors when managed by Terraform

After the change?

Added support for the copilot_code_review rule in repository rulesets
Users can now configure automatic Copilot code review for pull requests with two options:
review_new_pushes - Copilot automatically reviews each new push to the pull request (defaults to false)
review_draft_pull_requests - Copilot automatically reviews draft pull requests before they are marked as ready for review (defaults to false)
The implementation follows the existing pattern for other ruleset rules and is fully backwards compatible
Empty copilot_code_review {} block enables the feature with default settings (both options disabled), matching GitHub UI behavior

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

this feature is based on https://github.blog/changelog/2025-09-10-copilot-code-review-independent-repository-rule-for-automatic-reviews/ (an independent repository rule instead of pull request rule)

This change adds support for GitHub's Copilot code review feature in repository rulesets,
allowing automatic code review requests for pull requests.

Changes:
- Add copilot_code_review rule to repository ruleset schema
- Add CopilotCodeReviewRuleParameters and related types to go-github
- Implement expand/flatten logic for copilot_code_review rules

The copilot_code_review rule supports two configuration options:
- review_new_pushes: Automatically review each new push to the PR
- review_draft_pull_requests: Automatically review draft PRs

Both options default to false, matching GitHub UI behavior.
@github-actions github-actions bot added the Type: Feature New feature or request label Dec 4, 2025
Copy link
Contributor

@deiga deiga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't manually edit the vendored library. That code needs to be updated by upgrading the library itself.

This is happening in the v7 release

@JiayangZhou
Copy link
Author

JiayangZhou commented Dec 4, 2025

Thank you @deiga i have created a PR on google/go-github vendor side and will update this PR once that change is merged

@SoaAlex
Copy link

SoaAlex commented Dec 19, 2025

Hello, very interested in this feature, now that the go-google one is merged, is it OK here ?

@deiga
Copy link
Contributor

deiga commented Dec 19, 2025

Hey 👋

We'll still need to get the v7 upgrade of this provider done, so that go-github can be upgraded to the latest version. Then we can get this merged in!

@JiayangZhou
Copy link
Author

@SoaAlex the change I made in go module repo hasnt even been released yet, likely will be included in the v81 release in coming days, for github provider i see we are trying to push update to v77, i guess it will take some time for us to upgrade to v8. I will dust off this PR when we do that!

Also @deiga one observation I have is in github API, one of the parameters of enabling copilot is review_on_push, https://docs.github.com/en/rest/repos/rules?apiVersion=2022-11-28

but in UI, it is Review new pushes, I made another PR to address this issue in GH go module google/go-github#3874

but for terraform provider, should we respect UI more, in stead of API, maybe we should keep using review_new_pushes in docs and code

@deiga
Copy link
Contributor

deiga commented Dec 19, 2025

We hopefully won't be needing a v8 of the provider to upgrade to v80 of the SDK 😬

That's a fair question. I think we have the luxury of going whichever way we think is best and don't have to follow either naming necessarily.
What I mean is: which wording is clearer to a user of the provider? Of course if we're closer to the UI we enable non-terraform experts to contribute to IaC as they most likely know only the UI wording.
A IaC maintainer probably is more aware of the API wording but will also read the provider docs.

So: no answer, only questions 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: Add automatic_copilot_code_review_enabled support for repository rules

3 participants