From 0fffc3839f134e8a4344510c7263d408abc03cfe Mon Sep 17 00:00:00 2001 From: Michael Earl Date: Tue, 7 Oct 2025 16:30:12 -0700 Subject: [PATCH] feat: github_organization_ruleset - support do_not_enforce_on_create for required workflows --- github/resource_github_organization_ruleset.go | 6 ++++++ github/resource_github_organization_ruleset_test.go | 7 ------- website/docs/r/organization_ruleset.html.markdown | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/github/resource_github_organization_ruleset.go b/github/resource_github_organization_ruleset.go index e0a70c85b9..c6a5fcc89b 100644 --- a/github/resource_github_organization_ruleset.go +++ b/github/resource_github_organization_ruleset.go @@ -465,6 +465,12 @@ func resourceGithubOrganizationRuleset() *schema.Resource { }, }, }, + "do_not_enforce_on_create": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Whether or not to allow repository and branch creation without the required workflows passing.", + }, }, }, }, diff --git a/github/resource_github_organization_ruleset_test.go b/github/resource_github_organization_ruleset_test.go index 3b6530460c..2c8e47e781 100644 --- a/github/resource_github_organization_ruleset_test.go +++ b/github/resource_github_organization_ruleset_test.go @@ -21,7 +21,6 @@ func TestGithubOrganizationRulesets(t *testing.T) { randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum) t.Run("Creates and updates organization rulesets without errors", func(t *testing.T) { - config := fmt.Sprintf(` resource "github_organization_ruleset" "test" { name = "test-%s" @@ -150,11 +149,9 @@ func TestGithubOrganizationRulesets(t *testing.T) { t.Run("with an enterprise account", func(t *testing.T) { testCase(t, enterprise) }) - }) t.Run("Updates a ruleset name without error", func(t *testing.T) { - oldRSName := fmt.Sprintf(`ruleset-%[1]s`, randomID) newRSName := fmt.Sprintf(`%[1]s-renamed`, randomID) @@ -209,11 +206,9 @@ func TestGithubOrganizationRulesets(t *testing.T) { t.Run("with an enterprise account", func(t *testing.T) { testCase(t, enterprise) }) - }) t.Run("Imports rulesets without error", func(t *testing.T) { - config := fmt.Sprintf(` resource "github_organization_ruleset" "test" { name = "test-%s" @@ -292,7 +287,5 @@ func TestGithubOrganizationRulesets(t *testing.T) { t.Run("with an enterprise account", func(t *testing.T) { testCase(t, enterprise) }) - }) - } diff --git a/website/docs/r/organization_ruleset.html.markdown b/website/docs/r/organization_ruleset.html.markdown index 07f8608da5..6f0f6e028a 100644 --- a/website/docs/r/organization_ruleset.html.markdown +++ b/website/docs/r/organization_ruleset.html.markdown @@ -178,6 +178,8 @@ The `rules` block supports the following: * `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)) +* `do_not_enforce_on_create` - (Optional) (Boolean) Whether or not to allow repository and branch creation without the required workflows passing. + #### rules.required_workflows.required_workflow #### * `repository_id` - (Required) (Number) The ID of the repository. Names, full names and repository URLs are not supported.