diff --git a/github/resource_github_organization_ruleset.go b/github/resource_github_organization_ruleset.go index 014b28ef65..e4fb769f9a 100644 --- a/github/resource_github_organization_ruleset.go +++ b/github/resource_github_organization_ruleset.go @@ -235,6 +235,12 @@ func resourceGithubOrganizationRuleset() *schema.Resource { Description: "Choose which status checks must pass before branches can be merged into a branch that matches this rule. When enabled, commits must first be pushed to another branch, then merged or pushed directly to a branch that matches this rule after status checks have passed.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "do_not_enforce_on_create": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Allow repositories and branches to be created if a check would otherwise prohibit it.", + }, "required_check": { Type: schema.TypeSet, MinItems: 1, @@ -428,6 +434,12 @@ func resourceGithubOrganizationRuleset() *schema.Resource { Description: "Choose which Actions workflows must pass before branches can be merged into a branch that matches this rule.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "do_not_enforce_on_create": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Allow repositories and branches to be created if a check would otherwise prohibit it.", + }, "required_workflow": { Type: schema.TypeSet, MinItems: 1, diff --git a/github/respository_rules_utils.go b/github/respository_rules_utils.go index 44ccb27de1..0135f8b0f4 100644 --- a/github/respository_rules_utils.go +++ b/github/respository_rules_utils.go @@ -355,7 +355,6 @@ func expandRules(input []interface{}, org bool) []*github.RepositoryRule { requiredWorkflows := make([]*github.RuleRequiredWorkflow, 0) if requiredWorkflowsInput, ok := requiredWorkflowsMap["required_workflow"]; ok { - requiredWorkflowsSet := requiredWorkflowsInput.(*schema.Set) for _, workflowMap := range requiredWorkflowsSet.List() { workflow := workflowMap.(map[string]interface{}) @@ -375,7 +374,8 @@ func expandRules(input []interface{}, org bool) []*github.RepositoryRule { } params := &github.RequiredWorkflowsRuleParameters{ - RequiredWorkflows: requiredWorkflows, + RequiredWorkflows: requiredWorkflows, + DoNotEnforceOnCreate: requiredWorkflowsMap["do_not_enforce_on_create"].(bool), } rulesSlice = append(rulesSlice, github.NewRequiredWorkflowsRule(params)) } diff --git a/website/docs/r/organization_ruleset.html.markdown b/website/docs/r/organization_ruleset.html.markdown index 1f31a19b42..85ec0c542e 100644 --- a/website/docs/r/organization_ruleset.html.markdown +++ b/website/docs/r/organization_ruleset.html.markdown @@ -151,6 +151,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`. @@ -163,6 +165,8 @@ The `rules` block supports the following: #### rules.required_workflows #### +* `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_workflow` - (Required) (Block Set, Min: 1) Actions workflows that are required. Multiple can be defined. (see [below for nested schema](#rules.required_workflows.required_workflow)) #### rules.required_workflows.required_workflow ####