diff --git a/github_branch.tf b/github_branch.tf index 871e3f8..db022d7 100644 --- a/github_branch.tf +++ b/github_branch.tf @@ -34,10 +34,11 @@ locals { # https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch_protection resource "github_branch_protection" "main" { - enforce_admins = var.github_enforce_admins_branch_protection - pattern = var.github_default_branch + count = var.enforce_prs ? 1 : 0 + enforce_admins = var.github_enforce_admins_branch_protection + pattern = var.github_default_branch # push_restrictions = var.github_push_restrictions - repository_id = github_repository.repo.node_id + repository_id = github_repository.repo.node_id required_pull_request_reviews { dismiss_stale_reviews = var.github_dismiss_stale_reviews require_code_owner_reviews = var.github_require_code_owner_reviews diff --git a/github_files.tf b/github_files.tf index a1ef4d1..ca280c4 100644 --- a/github_files.tf +++ b/github_files.tf @@ -1,6 +1,6 @@ # https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_file resource "github_repository_file" "codeowners" { - count = var.create_codeowners ? 1 : 0 + count = var.create_codeowners ? 1 : 0 repository = github_repository.repo.name branch = var.github_default_branch file = "CODEOWNERS" diff --git a/variables.tf b/variables.tf index ab97845..43c5496 100644 --- a/variables.tf +++ b/variables.tf @@ -152,7 +152,12 @@ variable "pull_request_bypassers" { type = list(any) } -variable create_codeowners { +variable "create_codeowners" { default = true - type = bool + type = bool } + +variable "enforce_prs" { + default = true + type = bool +} \ No newline at end of file