diff --git a/terraform-scripts/quarkus-jgit.tf b/terraform-scripts/quarkus-jgit.tf index 65db4a9..c3f0b8e 100644 --- a/terraform-scripts/quarkus-jgit.tf +++ b/terraform-scripts/quarkus-jgit.tf @@ -34,3 +34,35 @@ resource "github_team_membership" "quarkus_jgit" { username = each.value role = "maintainer" } + +# Protect main branch using a ruleset +resource "github_repository_ruleset" "quarkus_jgit" { + name = "main" + repository = github_repository.quarkus_jgit.name + target = "branch" + enforcement = "active" + + conditions { + ref_name { + include = ["~DEFAULT_BRANCH"] + exclude = [] + } + } + + bypass_actors { + actor_id = data.github_app.quarkiverse_ci.id + actor_type = "Integration" + bypass_mode = "always" + } + + rules { + # Prevent force push + non_fast_forward = true + # Block branch deletion + deletion = true + + # Require pull request reviews before merging + pull_request { + } + } +}