Skip to content

feat/fix: Add missing do_not_enforce_on_create parameter to required rules #2659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions github/resource_github_organization_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions github/respository_rules_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand All @@ -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))
}
Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/organization_ruleset.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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 ####
Expand Down