diff --git a/github/resource_github_repository_ruleset.go b/github/resource_github_repository_ruleset.go index 2eb127061..ef18c5105 100644 --- a/github/resource_github_repository_ruleset.go +++ b/github/resource_github_repository_ruleset.go @@ -244,6 +244,11 @@ func resourceGithubRepositoryRuleset() *schema.Resource { }, }, }, + "do_not_enforce_on_create": { + Type: schema.TypeBool, + Optional: true, + Description: "Allow repositories and branches to be created if a check would otherwise prohibit it.", + }, "strict_required_status_checks_policy": { Type: schema.TypeBool, Optional: true, diff --git a/github/resource_github_repository_ruleset_test.go b/github/resource_github_repository_ruleset_test.go index a51682507..bb5288fb3 100644 --- a/github/resource_github_repository_ruleset_test.go +++ b/github/resource_github_repository_ruleset_test.go @@ -64,6 +64,7 @@ func TestGithubRepositoryRulesets(t *testing.T) { } required_status_checks { + do_not_enforce_on_create = true required_check { context = "ci" @@ -313,6 +314,7 @@ func TestGithubRepositoryRulesets(t *testing.T) { } required_status_checks { + do_not_enforce_on_create = true required_check { context = "ci" diff --git a/github/respository_rules_utils.go b/github/respository_rules_utils.go index 7a42c6feb..ba13f5216 100644 --- a/github/respository_rules_utils.go +++ b/github/respository_rules_utils.go @@ -325,6 +325,7 @@ func expandRules(input []interface{}, org bool) []*github.RepositoryRule { } params := &github.RequiredStatusChecksRuleParameters{ + DoNotEnforceOnCreate: requiredStatusMap["do_not_enforce_on_create"].(bool), RequiredStatusChecks: requiredStatusChecks, StrictRequiredStatusChecksPolicy: requiredStatusMap["strict_required_status_checks_policy"].(bool), } @@ -469,6 +470,7 @@ func flattenRules(rules []*github.RepositoryRule, org bool) []interface{} { } rule := make(map[string]interface{}) + rule["do_not_enforce_on_create"] = params.DoNotEnforceOnCreate rule["required_check"] = requiredStatusChecksSlice rule["strict_required_status_checks_policy"] = params.StrictRequiredStatusChecksPolicy rulesMap[v.Type] = []map[string]interface{}{rule} diff --git a/website/docs/r/repository_ruleset.html.markdown b/website/docs/r/repository_ruleset.html.markdown index e61e4132d..aa5d9cc9c 100644 --- a/website/docs/r/repository_ruleset.html.markdown +++ b/website/docs/r/repository_ruleset.html.markdown @@ -169,6 +169,8 @@ The `rules` block supports the following: #### rules.required_status_checks #### +* `do_not_enforce_on_create` - (Optional) (Boolean) Allow repositories and branches to be created if a check would otherwise prohibit it. Defaults to `false`. + * `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)) * `strict_required_status_checks_policy` - (Optional) (Boolean) Whether pull requests targeting a matching branch must be tested with the latest code. This setting will not take effect unless at least one status check is enabled. Defaults to `false`.