From 81046de6500cba48a777f731e8c25afeff174775 Mon Sep 17 00:00:00 2001 From: Kazik Pogoda Date: Sat, 23 Sep 2023 21:46:25 +0200 Subject: [PATCH] branch protection can be switched off for private+free repos --- repository/main.tf | 1 + repository/variables.tf | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/repository/main.tf b/repository/main.tf index cccd0f6..96e20b1 100644 --- a/repository/main.tf +++ b/repository/main.tf @@ -45,6 +45,7 @@ resource "github_repository" "this" { } resource "github_branch_protection" "main" { + count = var.branch_protection ? 1 : 0 repository_id = github_repository.this.node_id pattern = "main" allows_deletions = false diff --git a/repository/variables.tf b/repository/variables.tf index f348df7..37745c4 100644 --- a/repository/variables.tf +++ b/repository/variables.tf @@ -66,3 +66,9 @@ variable "topics" { type = list(string) default = null } + +variable "branch_protection" { + description = "Set to `true` to enable repository branch protection. For `private` repos on free plan it should be `false`" + type = bool + default = true +}