github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/providers/github/r/branch_protection.html.markdown (about) 1 --- 2 layout: "github" 3 page_title: "GitHub: github_branch_protection" 4 sidebar_current: "docs-github-resource-branch-protection" 5 description: |- 6 Protects a GitHub branch. 7 --- 8 9 # github\_branch\_protection 10 11 Protects a GitHub branch. 12 13 This resource allows you to configure branch protection for repositories in your organization. When applied, the branch will be protected from forced pushes and deletion. Additional constraints, such as required status checks or restrictions on users and teams, can also be configured. 14 15 ## Example Usage 16 17 ``` 18 # Protect the master branch of the foo repository. Additionally, require that 19 # the "ci/travis" context to be passing and only allow the engineers team merge 20 # to the branch. 21 resource "github_branch_protection" "foo_master" { 22 repository = "foo" 23 branch = "master" 24 25 required_status_checks { 26 include_admins = true 27 strict = false 28 contexts = ["ci/travis"] 29 } 30 31 required_pull_request_reviews { 32 include_admins = true 33 } 34 35 restrictions { 36 teams = ["engineers"] 37 } 38 } 39 ``` 40 41 ## Argument Reference 42 43 The following arguments are supported: 44 45 * `repository` - (Required) The GitHub repository name. 46 * `branch` - (Required) The Git branch to protect. 47 * `required_status_checks` - (Optional) Enforce restrictions for required status checks. See [Required Status Checks](#required-status-checks) below for details. 48 * `required_pull_request_reviews` - (Optional) Enforce restrictions for pull request reviews. See [Required Pull Request Reviews](#required-pull-request-reviews) below for details. 49 * `restrictions` - (Optional) Enforce restrictions for the users and teams that may push to the branch. See [Restrictions](#restrictions) below for details. 50 51 ### Required Status Checks 52 53 `required_status_checks` supports the following arguments: 54 55 * `include_admins`: (Optional) Enforce required status checks for repository administrators. Defaults to `false`. 56 * `strict`: (Optional) Require branches to be up to date before merging. Defaults to `false`. 57 * `contexts`: (Optional) The list of status checks to require in order to merge into this branch. No status checks are required by default. 58 59 ### Required Pull Request Reviews 60 61 `required_pull_request_reviews` supports the following arguments: 62 63 * `include_admins`: (Optional) Enforce required status checks for repository administrators. Defaults to `false`. 64 65 ### Restrictions 66 67 `restrictions` supports the following arguments: 68 69 * `users`: (Optional) The list of user logins with push access. 70 * `teams`: (Optional) The list of team slugs with push access. 71 72 `restrictions` is only available for organization-owned repositories.