|
| 1 | +# GitHub repository branch protection rules |
| 2 | + |
| 3 | +Add branch protection rule to your GitHub repository |
| 4 | + |
| 5 | +## Authentication |
| 6 | + |
| 7 | +- you must create a github app or a classic token with admin rights |
| 8 | +- then add the following in your provider configuration : |
| 9 | + |
| 10 | +reference: https://registry.terraform.io/providers/integrations/github/latest/docs |
| 11 | + |
| 12 | +### using an app (recommended) |
| 13 | + |
| 14 | +```hcl |
| 15 | +provider "github" { |
| 16 | + owner = var.github_organization |
| 17 | + # set one of GITHUB_APP_ID, GITHUB_APP_INSTALLATION_ID, GITHUB_APP_PEM_FILE env var |
| 18 | + app_auth {} |
| 19 | +} |
| 20 | +``` |
| 21 | + |
| 22 | +### using a github token (classic) |
| 23 | + |
| 24 | +```hcl |
| 25 | +provider "github" { |
| 26 | + owner = var.github_organization |
| 27 | + # and set GITHUB_TOKEN env var in your shell |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 32 | +## Requirements |
| 33 | + |
| 34 | +| Name | Version | |
| 35 | +|------|---------| |
| 36 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.3 | |
| 37 | +| <a name="requirement_github"></a> [github](#requirement\_github) | ~> 6.0 | |
| 38 | +| <a name="requirement_time"></a> [time](#requirement\_time) | ~> 0.9.1 | |
| 39 | + |
| 40 | +## Providers |
| 41 | + |
| 42 | +| Name | Version | |
| 43 | +|------|---------| |
| 44 | +| <a name="provider_github"></a> [github](#provider\_github) | ~> 6.0 | |
| 45 | +| <a name="provider_time"></a> [time](#provider\_time) | ~> 0.9.1 | |
| 46 | + |
| 47 | +## Modules |
| 48 | + |
| 49 | +No modules. |
| 50 | + |
| 51 | +## Resources |
| 52 | + |
| 53 | +| Name | Type | |
| 54 | +|------|------| |
| 55 | +| [github_branch_protection.main](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch_protection) | resource | |
| 56 | +| [time_static.last_update](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | resource | |
| 57 | + |
| 58 | +## Inputs |
| 59 | + |
| 60 | +| Name | Description | Type | Default | Required | |
| 61 | +|------|-------------|------|---------|:--------:| |
| 62 | +| <a name="input_allows_deletions"></a> [allows\_deletions](#input\_allows\_deletions) | Allow branch deletions | `bool` | `false` | no | |
| 63 | +| <a name="input_allows_force_pushes"></a> [allows\_force\_pushes](#input\_allows\_force\_pushes) | Allow force pushes | `bool` | `false` | no | |
| 64 | +| <a name="input_branch_pattern"></a> [branch\_pattern](#input\_branch\_pattern) | Branch name pattern to protect | `string` | `"main"` | no | |
| 65 | +| <a name="input_customer"></a> [customer](#input\_customer) | Customer for the current deployment | `string` | `""` | no | |
| 66 | +| <a name="input_enforce_admins"></a> [enforce\_admins](#input\_enforce\_admins) | Enforce required status checks for repository administrators | `bool` | `true` | no | |
| 67 | +| <a name="input_environment"></a> [environment](#input\_environment) | Environment for the current deployment | `string` | `""` | no | |
| 68 | +| <a name="input_force_push_bypassers"></a> [force\_push\_bypassers](#input\_force\_push\_bypassers) | List of actor IDs that can bypass force push restrictions | `any` | `[]` | no | |
| 69 | +| <a name="input_lock_branch"></a> [lock\_branch](#input\_lock\_branch) | Lock the branch | `bool` | `false` | no | |
| 70 | +| <a name="input_name"></a> [name](#input\_name) | The name of the branch protection rule | `string` | n/a | yes | |
| 71 | +| <a name="input_repository_id"></a> [repository\_id](#input\_repository\_id) | Name or id of the GitHub repository to protect | `string` | n/a | yes | |
| 72 | +| <a name="input_require_conversation_resolution"></a> [require\_conversation\_resolution](#input\_require\_conversation\_resolution) | Require conversation resolution before merging | `bool` | `true` | no | |
| 73 | +| <a name="input_require_signed_commits"></a> [require\_signed\_commits](#input\_require\_signed\_commits) | Require commits to be signed | `bool` | `true` | no | |
| 74 | +| <a name="input_required_linear_history"></a> [required\_linear\_history](#input\_required\_linear\_history) | Enforce a linear commit history | `bool` | `true` | no | |
| 75 | +| <a name="input_required_pull_request_reviews"></a> [required\_pull\_request\_reviews](#input\_required\_pull\_request\_reviews) | Require pull request reviews before merging | `any` | `{}` | no | |
| 76 | +| <a name="input_required_status_checks"></a> [required\_status\_checks](#input\_required\_status\_checks) | Require status checks to pass before merging | `any` | `{}` | no | |
| 77 | +| <a name="input_restrict_pushes"></a> [restrict\_pushes](#input\_restrict\_pushes) | Restrict who can push to the branch | `any` | `{}` | no | |
| 78 | +| <a name="input_tags"></a> [tags](#input\_tags) | Default tags to add to resources | `map(any)` | `{}` | no | |
| 79 | + |
| 80 | +## Outputs |
| 81 | + |
| 82 | +No outputs. |
| 83 | +<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
0 commit comments