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)

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 😂

@Invincibear
Copy link

My vote is on following the API's property name; review_on_push

@deiga
Copy link
Contributor

deiga commented Jan 9, 2026

@JiayangZhou We've been able to upgrade to the latest go-github version now without needing a major version bump! Feel free to finalize this PR now :)

@JiayangZhou JiayangZhou force-pushed the feature/copilot-code-review-ruleset branch from fad71e6 to 89460b9 Compare January 9, 2026 17:19
@JiayangZhou JiayangZhou requested a review from deiga January 9, 2026 17:37
@deiga
Copy link
Contributor

deiga commented Jan 13, 2026

Resolves #2641

@stevehipwell
Copy link
Collaborator

@JiayangZhou could you please rebase this PR so I can enable the automation. Also have you run the tests locally, if so could you please provide a screenshot?

@nickfloyd nickfloyd added this to the v6.10.0 Release milestone Jan 13, 2026
@JiayangZhou
Copy link
Author

Hi @stevehipwell are you referencing to the acceptance test?
Screenshot 2026-01-14 at 09 57 07

  1. Created a repository tf-acc-test-copilot-XXXXX on GitHub
  2. Created a ruleset with copilot_code_review rule
  3. Verified review_on_push = true
  4. Verified review_draft_pull_requests = false
  5. Cleaned up the resources

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.
@stevehipwell stevehipwell force-pushed the feature/copilot-code-review-ruleset branch from 9978a3d to 94f4104 Compare January 14, 2026 13:13
@stevehipwell
Copy link
Collaborator

@JiayangZhou could you please also make these changes to the organization ruleset resource?

This extends the copilot_code_review feature to github_organization_ruleset
resource, matching the functionality already available in github_repository_ruleset.

Changes:
- Add copilot_code_review schema to organization ruleset resource
- Update organization ruleset acceptance test with copilot_code_review
- Add documentation for copilot_code_review in organization_ruleset.html.markdown
@JiayangZhou
Copy link
Author

Added the same for org rulesets, good you spotted that it exists there too! All tests passed.
Screenshot 2026-01-14 at 21 25 55

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

6 participants