Skip to content

Latest commit

 

History

History
84 lines (64 loc) · 4.17 KB

File metadata and controls

84 lines (64 loc) · 4.17 KB

GitHub repository branch protection rules

Add branch protection rule to your GitHub repository

Authentication

  • you must create a GitHub app or a classic token with admin rights
  • then add the following in your provider configuration :

reference: https://registry.terraform.io/providers/integrations/github/latest/docs

using an app (recommended)

provider "github" {
  owner = var.github_organization
  # set one of GITHUB_APP_ID, GITHUB_APP_INSTALLATION_ID, GITHUB_APP_PEM_FILE env var
  app_auth {}
}

using a GitHub token (classic)

provider "github" {
  owner = var.github_organization
  # and set GITHUB_TOKEN env var in your shell
}

Requirements

Name Version
terraform ~> 1.3
github ~> 6.0
time ~> 0.9.1

Providers

Name Version
github ~> 6.0
time ~> 0.9.1

Modules

No modules.

Resources

Name Type
github_branch_protection.main resource
time_static.last_update resource

Inputs

Name Description Type Default Required
allows_deletions Allow branch deletions bool false no
allows_force_pushes Allow force pushes bool false no
branch_pattern Branch name pattern to protect string "main" no
customer Customer for the current deployment string "" no
enforce_admins Enforce required status checks for repository administrators bool true no
force_push_bypassers List of actor IDs that can bypass force push restrictions any [] no
lock_branch Lock the branch bool false no
name The name of the branch protection rule string n/a yes
repository_id Name or id of the GitHub repository to protect string n/a yes
require_conversation_resolution Require conversation resolution before merging bool true no
require_signed_commits Require commits to be signed bool true no
required_linear_history Enforce a linear commit history bool true no
required_pull_request_reviews Require pull request reviews before merging any {} no
required_status_checks Require status checks to pass before merging any {} no
restrict_pushes Restrict who can push to the branch any {} no
tags Default tags to add to resources map(any) {} no

Outputs

Name Description
id The ID of the branch protection rule