Skip to content

Terraform module that allows to create branch protection for github repositories

Notifications You must be signed in to change notification settings

masterborn/terraform-github-default-branch-protection

Repository files navigation

terraform-github-default-branch-protection

Resource that allows to declare branch protection rules for repository.

Requirements

Name Version
terraform >= 0.13
github < 5.0

Providers

Name Version
github < 5.0

Resources

Name Type
github_branch_protection.develop resource
github_branch_protection.main resource
github_branch_protection.master resource
github_branch_protection.stage resource
github_branch_protection.staging resource

Inputs

Name Description Type Default Required
repository_name GitHub repository name string n/a yes
develop_context The list of status checks to require in order to merge into develop. Default: no checks. list(string) [] no
stage_context The list of status checks to require in order to merge into stage. Default: no checks. list(string) [] no
master_context The list of status checks to require in order to merge into master. Default: no checks. list(string) [] no
main_context The list of status checks to require in order to merge into main. Default: no checks. list(string) [] no
use_develop Indicate the existence of a develop branch. bool false no
use_stage Indicate the existence of a stage branch. bool false no
use_master Indicate the existence of a master branch. bool false no
use_main Indicate the existence of a main branch. bool true no

Examples

Basic example

module "some-project-branch-protection" {
  source = "[email protected]:masterborn/terraform-github-default-branch-protection.git?ref=v1.1.0"

  repository_name = module.some-project.repository_name
  use_develop     = true
  use_stage       = true
  use_master      = true
}

Example with main branch

This will create only main branch:

module "some-project-branch-protection" {
  source = "[email protected]:masterborn/terraform-github-default-branch-protection.git?ref=v1.1.0"

  repository_name = module.some-project.repository_name
}

Enabling pre-commit hooks

Following pre-commit hooks are provided:

Requirements

Installation

To install pre-commit check .

pre-commit install

About

Terraform module that allows to create branch protection for github repositories

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages