Skip to content
Merged
Changes from all 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
23 changes: 13 additions & 10 deletions gh-protections.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Every active repository requires a pull request with its configured CI checks
# passing before merge, except repositories explicitly assigned the relaxed
# protection profile below. The check map lives in main.tf because check-run
# names differ by repository and GitHub treats an unknown required check as
# pending.
# Every active public repository requires a pull request with its configured CI
# checks passing before merge, except repositories explicitly assigned the
# relaxed protection profile below. Private repositories are deliberately
# excluded: GitHub Free cannot enforce these protections there, and personal
# private repositories are outside the organization's review policy. The check
# map lives in main.tf because check-run names differ by repository and GitHub
# treats an unknown required check as pending.
resource "github_branch_protection" "protections" {
for_each = toset([
for repo in local.github_repositories : repo
if !contains(local.archived_github_repositories, repo) && !contains(local.relaxed_branch_protection_github_repositories, repo)
if !contains(local.archived_github_repositories, repo) && !contains(local.private_github_repositories, repo) && !contains(local.relaxed_branch_protection_github_repositories, repo)
])

repository_id = github_repository.repositories[each.key].node_id
Expand Down Expand Up @@ -43,13 +45,14 @@ resource "github_branch_protection" "protections" {
]
}

# Personal knowledge repositories retain pull-request-only writes and basic
# branch integrity, while allowing any pull request to merge without a CI,
# approval, code-owner, or conversation-resolution gate.
# The relaxed profile is for public personal repositories: pull-request-only
# writes and basic branch integrity, while allowing any pull request to merge
# without a CI, approval, code-owner, or conversation-resolution gate. Private
# repositories are deliberately excluded from all branch-protection resources.
resource "github_branch_protection" "relaxed_protections" {
for_each = toset([
for repo in local.relaxed_branch_protection_github_repositories : repo
if !contains(local.archived_github_repositories, repo)
if !contains(local.archived_github_repositories, repo) && !contains(local.private_github_repositories, repo)
])

repository_id = github_repository.repositories[each.key].node_id
Expand Down
Loading