Skip to content

Commit

Permalink
conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Jan 22, 2024
1 parent bc4209b commit c2b77a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
20 changes: 20 additions & 0 deletions terraform/modules/github_repository/branch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,23 @@ resource "github_branch_protection" "main" {
required_approving_review_count = 0
}
}


resource "github_branch_protection" "next-release" {
# Branch protection can only be enabled on private repositories if using a
# paid GitHub plan
count = var.visibility == "public" ? var.has_release_branches ? 1 : 0 : 0

repository_id = github_repository.repository.node_id
pattern = "next-*"
enforce_admins = true
required_linear_history = false
allows_deletions = false
allows_force_pushes = true
blocks_creations = false

required_status_checks {
strict = true
contexts = null
}
}
21 changes: 0 additions & 21 deletions terraform/modules/github_repository/repository.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,4 @@ resource "github_repository" "repository" {
}
}
}

dynamic "github_branch_protection" {
for_each = var.has_release_branches ? [1] : []

content {
count = var.visibility == "public" ? 1 : 0

repository_id = github_repository.repository.node_id
pattern = "next-*"
enforce_admins = true
required_linear_history = false
allows_deletions = false
allows_force_pushes = true
blocks_creations = false

required_status_checks {
strict = true
contexts = null
}
}
}
}

0 comments on commit c2b77a2

Please sign in to comment.