Skip to content

Commit

Permalink
adding conditional on prs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Arnold committed May 7, 2024
1 parent 82cb3e1 commit ad91543
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
7 changes: 4 additions & 3 deletions github_branch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion github_files.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
9 changes: 7 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit ad91543

Please sign in to comment.