@@ -184,6 +184,102 @@ resource "github_organization_ruleset" "test" {
184184 })
185185 })
186186
187+ t .Run ("creates_branch_ruleset_with_user_bypass_actor" , func (t * testing.T ) {
188+ randomID := acctest .RandString (5 )
189+ repoName := fmt .Sprintf ("%srepo-org-ruleset-%s" , testResourcePrefix , randomID )
190+ rulesetName := fmt .Sprintf ("%s-branch-ruleset-%s" , testResourcePrefix , randomID )
191+
192+ config := fmt .Sprintf (`
193+ resource "github_repository" "test" {
194+ name = "%s"
195+ visibility = "private"
196+ auto_init = true
197+ }
198+
199+ data "github_user" "current" {
200+ username = "%[3]s"
201+ }
202+
203+ resource "github_organization_ruleset" "test" {
204+ name = "%[2]s"
205+ target = "branch"
206+ enforcement = "active"
207+
208+ bypass_actors {
209+ actor_type = "User"
210+ bypass_mode = "always"
211+ actor_id = tonumber(data.github_user.current.id)
212+ }
213+
214+ conditions {
215+ repository_name {
216+ include = ["~ALL"]
217+ exclude = []
218+ }
219+
220+ ref_name {
221+ include = ["~ALL"]
222+ exclude = []
223+ }
224+ }
225+
226+ rules {
227+ creation = true
228+
229+ update = true
230+
231+ deletion = true
232+ required_linear_history = true
233+
234+ required_signatures = false
235+
236+ pull_request {
237+ required_approving_review_count = 2
238+ required_review_thread_resolution = true
239+ require_code_owner_review = true
240+ dismiss_stale_reviews_on_push = true
241+ require_last_push_approval = true
242+ }
243+
244+ copilot_code_review {
245+ review_on_push = true
246+ review_draft_pull_requests = false
247+ }
248+
249+ required_status_checks {
250+
251+ required_check {
252+ context = "ci"
253+ }
254+
255+ strict_required_status_checks_policy = true
256+ do_not_enforce_on_create = true
257+ }
258+
259+ non_fast_forward = true
260+ }
261+ }
262+ ` , repoName , rulesetName , testAccConf .username )
263+
264+ resource .Test (t , resource.TestCase {
265+ PreCheck : func () { skipUnlessHasPaidOrgs (t ) },
266+ ProviderFactories : providerFactories ,
267+ Steps : []resource.TestStep {
268+ {
269+ Config : config ,
270+ ConfigStateChecks : []statecheck.StateCheck {
271+ statecheck .ExpectKnownValue ("github_organization_ruleset.test" , tfjsonpath .New ("name" ), knownvalue .StringExact (rulesetName )),
272+ statecheck .ExpectKnownValue ("github_organization_ruleset.test" , tfjsonpath .New ("target" ), knownvalue .StringExact ("branch" )),
273+ statecheck .ExpectKnownValue ("github_organization_ruleset.test" , tfjsonpath .New ("enforcement" ), knownvalue .StringExact ("active" )),
274+ statecheck .ExpectKnownValue ("github_organization_ruleset.test" , tfjsonpath .New ("bypass_actors" ).AtSliceIndex (0 ).AtMapKey ("actor_type" ), knownvalue .StringExact ("User" )),
275+ statecheck .ExpectKnownValue ("github_organization_ruleset.test" , tfjsonpath .New ("bypass_actors" ).AtSliceIndex (0 ).AtMapKey ("bypass_mode" ), knownvalue .StringExact ("always" )),
276+ statecheck .ExpectKnownValue ("github_organization_ruleset.test" , tfjsonpath .New ("bypass_actors" ).AtSliceIndex (0 ).AtMapKey ("actor_id" ), knownvalue .NotNull ()),
277+ },
278+ },
279+ },
280+ })
281+ })
282+
187283 t .Run ("create_ruleset_with_repository_property" , func (t * testing.T ) {
188284 randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
189285 rulesetName := fmt .Sprintf ("%s-repo-prop-ruleset-%s" , testResourcePrefix , randomID )
0 commit comments