@@ -74,11 +74,6 @@ resource "github_organization_ruleset" "test" {
7474 bypass_mode = "always"
7575 }
7676
77- bypass_actors {
78- actor_type = "EnterpriseOwner"
79- bypass_mode = "always"
80- }
81-
8277 conditions {
8378 repository_name {
8479 include = ["~ALL"]
@@ -163,16 +158,14 @@ resource "github_organization_ruleset" "test" {
163158 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "name" , rulesetName ),
164159 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "target" , "branch" ),
165160 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "enforcement" , "active" ),
166- resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.#" , "4 " ),
161+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.#" , "3 " ),
167162 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.0.actor_type" , "DeployKey" ),
168163 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.0.bypass_mode" , "always" ),
169164 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.1.actor_id" , "5" ),
170165 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.1.actor_type" , "RepositoryRole" ),
171166 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.1.bypass_mode" , "always" ),
172167 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.2.actor_type" , "OrganizationAdmin" ),
173168 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.2.bypass_mode" , "always" ),
174- resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.3.actor_type" , "EnterpriseOwner" ),
175- resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.3.bypass_mode" , "always" ),
176169 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "rules.0.pull_request.0.allowed_merge_methods.#" , "3" ),
177170 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "rules.0.required_workflows.0.do_not_enforce_on_create" , "true" ),
178171 resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "rules.0.required_workflows.0.required_workflow.0.path" , workflowFilePath ),
@@ -187,6 +180,62 @@ resource "github_organization_ruleset" "test" {
187180 })
188181 })
189182
183+ t .Run ("create_branch_ruleset_with_enterprise_features" , func (t * testing.T ) {
184+ randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
185+ rulesetName := fmt .Sprintf ("%s-branch-ruleset-%s" , testResourcePrefix , randomID )
186+
187+ config := fmt .Sprintf (`
188+ resource "github_organization_ruleset" "test" {
189+ name = "%s"
190+ target = "branch"
191+ enforcement = "active"
192+
193+ conditions {
194+ ref_name {
195+ include = ["~ALL"]
196+ exclude = []
197+ }
198+
199+ repository_name {
200+ include = ["~ALL"]
201+ exclude = []
202+ }
203+ }
204+
205+ bypass_actors {
206+ actor_type = "EnterpriseOwner"
207+ bypass_mode = "always"
208+ }
209+
210+ rules {
211+ branch_name_pattern {
212+ name = "test"
213+ negate = false
214+ operator = "starts_with"
215+ pattern = "test"
216+ }
217+ }
218+ }
219+ ` , rulesetName )
220+
221+ resource .Test (t , resource.TestCase {
222+ PreCheck : func () { skipUnlessEnterprise (t ) },
223+ ProviderFactories : providerFactories ,
224+ Steps : []resource.TestStep {
225+ {
226+ Config : config ,
227+ Check : resource .ComposeTestCheckFunc (
228+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "name" , rulesetName ),
229+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "enforcement" , "active" ),
230+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.#" , "1" ),
231+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.0.actor_type" , "EnterpriseOwner" ),
232+ resource .TestCheckResourceAttr ("github_organization_ruleset.test" , "bypass_actors.0.bypass_mode" , "always" ),
233+ ),
234+ },
235+ },
236+ })
237+ })
238+
190239 t .Run ("create_push_ruleset" , func (t * testing.T ) {
191240 randomID := acctest .RandStringFromCharSet (5 , acctest .CharSetAlphaNum )
192241 rulesetName := fmt .Sprintf ("%s-push-ruleset-%s" , testResourcePrefix , randomID )
0 commit comments