Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions github/resource_github_organization_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
Optional: true,
Description: "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`.",
},
"do_not_enforce_on_create": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually also need it on the required_workflows struct too

Copy link
Collaborator

@anGie44 anGie44 Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on the error you could prevent future panics in

doNotEnforceOnCreate := requiredStatusMap["do_not_enforce_on_create"].(bool)
params := &github.RequiredStatusChecksRuleParameters{
RequiredStatusChecks: requiredStatusChecks,
StrictRequiredStatusChecksPolicy: requiredStatusMap["strict_required_status_checks_policy"].(bool),
DoNotEnforceOnCreate: &doNotEnforceOnCreate,
}
as well by doing something like

		params := &github.RequiredStatusChecksRuleParameters{
			RequiredStatusChecks:             requiredStatusChecks,
		}

		if v, ok := requiredStatusMap["do_not_enforce_on_create"].(bool); ok {
			params.DoNotEnforceOnCreate =  &v
                }

                if v, ok := requiredStatusMap["strict_required_status_checks_policy"].(bool); ok {
                       params.StrictRequiredStatusChecksPolicy = v
                }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(but the Default: false should prevent that from happening 😅 )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the status on this?

Type: schema.TypeBool,
Optional: true,
Description: "Allow repositories and branches to be created if a check would otherwise prohibit it.",
Default: false,
},
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions github/resource_github_organization_ruleset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func TestGithubOrganizationRulesets(t *testing.T) {
}

strict_required_status_checks_policy = true
do_not_enforce_on_create = true
}

required_workflows {
Expand Down Expand Up @@ -218,6 +219,7 @@ func TestGithubOrganizationRulesets(t *testing.T) {
}

strict_required_status_checks_policy = true
do_not_enforce_on_create = true
}

branch_name_pattern {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/organization_ruleset.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ The `rules` block supports the following:

* `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`.

* `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_status_checks.required_check ####

* `context` - (Required) (String) The status check context name that must be present on the commit.
Expand Down