feat: Add support for Copilot code review in repository rulesets
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)
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] 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
- [x] 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)
Thank you @deiga i have created a PR on google/go-github vendor side and will update this PR once that change is merged
Hello, very interested in this feature, now that the go-google one is merged, is it OK here ?
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!
@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 https://github.com/google/go-github/pull/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
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 😂