Define all GitHub rulesets as ruleset/ files
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful

This commit is contained in:
2026-11-14 19:25:07 +11:00
parent a82e91d941
commit 5a786be0e6
11 changed files with 176 additions and 238 deletions
+42 -3
View File
@@ -15,14 +15,53 @@ module "repository" {
for_each = var.repository
owner = var.owner
config = each.value
rulesets = { for rs in each.value.rulesets : rs => var.ruleset[rs] }
owner = var.owner
config = each.value
team_slugs = {
for e in concat(each.value.maintainers, each.value.codeowners) : trimprefix(e, "@") => module.team[trimprefix(e, "@")].slug if startswith(e, "@")
}
}
locals {
# rulesets are not enforced on private repositories on the GitHub free plan
ruleset_pairs = merge([for repo_name, repo in var.repository : {
for rs in setunion(repo.rulesets, repo.private ? [] : [for k, v in var.ruleset : k if v.all_repos && !contains(repo.exclude_rulesets, k)]) :
"${repo_name}/${rs}" => { repository = repo_name, ruleset = rs }
}]...)
}
module "ruleset" {
source = "./modules/ruleset"
for_each = local.ruleset_pairs
repository = module.repository[each.value.repository].repository.name
ruleset = var.ruleset[each.value.ruleset]
# CODEOWNERS must exist before pull_request rules land
depends_on = [module.repository]
}
moved {
from = module.repository[".github"].module.ruleset["branch-protection"].github_repository_ruleset.this
to = module.ruleset[".github/branch-protection"].github_repository_ruleset.this
}
moved {
from = module.repository[".github"].module.ruleset["tag-protection"].github_repository_ruleset.this
to = module.ruleset[".github/tag-protection"].github_repository_ruleset.this
}
moved {
from = module.repository[".github"].module.ruleset["ref-names-branch"].github_repository_ruleset.this
to = module.ruleset[".github/ref-names-branch"].github_repository_ruleset.this
}
moved {
from = module.repository[".github"].module.ruleset["ref-names-tag"].github_repository_ruleset.this
to = module.ruleset[".github/ref-names-tag"].github_repository_ruleset.this
}
resource "github_actions_organization_workflow_permissions" "this" {
count = var.settings == null ? 0 : 1