Skip to content

Commit 01c3e69

Browse files
committed
feat: Add copilot_code_review support to organization ruleset
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
1 parent 94f4104 commit 01c3e69

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

github/resource_github_organization_ruleset.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,28 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
241241
},
242242
},
243243
},
244+
"copilot_code_review": {
245+
Type: schema.TypeList,
246+
Optional: true,
247+
MaxItems: 1,
248+
Description: "Automatically request Copilot code review for new pull requests if the author has access to Copilot code review and their premium requests quota has not reached the limit.",
249+
Elem: &schema.Resource{
250+
Schema: map[string]*schema.Schema{
251+
"review_on_push": {
252+
Type: schema.TypeBool,
253+
Optional: true,
254+
Default: false,
255+
Description: "Copilot automatically reviews each new push to the pull request. Defaults to `false`.",
256+
},
257+
"review_draft_pull_requests": {
258+
Type: schema.TypeBool,
259+
Optional: true,
260+
Default: false,
261+
Description: "Copilot automatically reviews draft pull requests before they are marked as ready for review. Defaults to `false`.",
262+
},
263+
},
264+
},
265+
},
244266
"required_status_checks": {
245267
Type: schema.TypeList,
246268
MaxItems: 1,

github/resource_github_organization_ruleset_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ resource "github_organization_ruleset" "test" {
103103
require_last_push_approval = true
104104
}
105105
106+
copilot_code_review {
107+
review_on_push = true
108+
review_draft_pull_requests = false
109+
}
110+
106111
required_status_checks {
107112
108113
required_check {
@@ -166,6 +171,8 @@ resource "github_organization_ruleset" "test" {
166171
resource.TestCheckResourceAttr("github_organization_ruleset.test", "rules.0.required_code_scanning.0.required_code_scanning_tool.0.alerts_threshold", "errors"),
167172
resource.TestCheckResourceAttr("github_organization_ruleset.test", "rules.0.required_code_scanning.0.required_code_scanning_tool.0.security_alerts_threshold", "high_or_higher"),
168173
resource.TestCheckResourceAttr("github_organization_ruleset.test", "rules.0.required_code_scanning.0.required_code_scanning_tool.0.tool", "CodeQL"),
174+
resource.TestCheckResourceAttr("github_organization_ruleset.test", "rules.0.copilot_code_review.0.review_on_push", "true"),
175+
resource.TestCheckResourceAttr("github_organization_ruleset.test", "rules.0.copilot_code_review.0.review_draft_pull_requests", "false"),
169176
),
170177
},
171178
},

website/docs/r/organization_ruleset.html.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ The `rules` block supports the following:
136136

137137
* `pull_request` - (Optional) (Block List, Max: 1) Require all commits be made to a non-target branch and submitted via a pull request before they can be merged. (see [below for nested schema](#rules.pull_request))
138138

139+
* `copilot_code_review` - (Optional) (Block List, Max: 1) Automatically request Copilot code review for new pull requests if the author has access to Copilot code review and their premium requests quota has not reached the limit. (see [below for nested schema](#rulescopilot_code_review))
140+
139141
* `required_linear_history` - (Optional) (Boolean) Prevent merge commits from being pushed to matching branches.
140142

141143
* `required_signatures` - (Optional) (Boolean) Commits pushed to matching branches must have verified signatures.
@@ -210,6 +212,12 @@ The `rules` block supports the following:
210212

211213
* `required_review_thread_resolution` - (Optional) (Boolean) All conversations on code must be resolved before a pull request can be merged. Defaults to `false`.
212214

215+
#### rules.copilot_code_review ####
216+
217+
* `review_on_push` - (Optional) (Boolean) Copilot automatically reviews each new push to the pull request. Defaults to `false`.
218+
219+
* `review_draft_pull_requests` - (Optional) (Boolean) Copilot automatically reviews draft pull requests before they are marked as ready for review. Defaults to `false`.
220+
213221
#### rules.required_status_checks ####
214222

215223
* `required_check` - (Required) (Block Set, Min: 1) Status checks that are required. Several can be defined. (see [below for nested schema](#rules.required_status_checks.required_check))

0 commit comments

Comments
 (0)