aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ops/github/repositories.tf13
1 files changed, 13 insertions, 0 deletions
diff --git a/ops/github/repositories.tf b/ops/github/repositories.tf
index 506f0dd..2465d43 100644
--- a/ops/github/repositories.tf
+++ b/ops/github/repositories.tf
@@ -19,3 +19,16 @@ resource "github_repository" "repos" {
vulnerability_alerts = try(each.value.vulnerability_alerts, false)
delete_branch_on_merge = try(each.value.vulnerability_alerts, false)
}
+
+resource "github_branch_default" "main" {
+ # no need to set the default branch if the repository is already
+ # archived.
+ # use the name for the repository if set
+ for_each = {
+ for k, v in local.repositories : try(v.name, k) => v
+ if v.archived == false
+ }
+
+ repository = each.key
+ branch = try(each.value.default_branch, "main")
+}