Skip to content

Commit

Permalink
Fix to the branch protection setup (#16)
Browse files Browse the repository at this point in the history
* known issue (integrations/terraform-provider-github#1147), trying this workaround before changing the provider version
* change to v4 graphql branch protection
  • Loading branch information
charlesmmarshall committed Feb 16, 2023
1 parent 7d87f25 commit 4c32a81
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v1
with:
terraform_version: 0.14.7
terraform_version: 1.3.7
- name: terraform fmt
run: |
terraform fmt -check -recursive
Expand Down
35 changes: 17 additions & 18 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions github_repository.tf
Expand Up @@ -59,11 +59,12 @@ resource "github_branch_default" "default" {
branch = var.default_branch_name
}

resource "github_branch_protection_v3" "repository_main" {

resource "github_branch_protection" "repository_main" {
count = var.branch_protection_enabled == true ? 1 : 0

repository = github_repository.repository.name
branch = var.default_branch_name
repository_id = github_repository.repository.name
pattern = var.default_branch_name
enforce_admins = var.enforce_admins

required_status_checks {
Expand All @@ -86,5 +87,7 @@ resource "github_actions_secret" "repository_secret" {
repository = github_repository.repository.name
secret_name = each.key
plaintext_value = each.value


}

2 changes: 1 addition & 1 deletion terraform.tf
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
github = {
source = "integrations/github"
version = "4.26.1"
version = "4.31.0"
}
}
required_version = ">= 1.0.0"
Expand Down

0 comments on commit 4c32a81

Please sign in to comment.