This repository contains code to manage GitHub repository branch protection rules for HMCTS.
This Terraform configuration automates the process of setting up rule sets at the organisation level.
Repository Type | Count |
---|---|
Production Repositories | 311 |
Development Repositories | 0 |
- Terraform (version 1.5.7 or later)
- Oauth or PAT Token with appropriate permissions.
- Reads a list of repositories from
production-repos.json
- Creates a ruleset at the organisation level, this applies standardisation across all repositories.
- Creates custom properties for repositories, such as marking repositories as "is_production."
- A good note to make is that you do not have to update this codebase as it will pull any new production repositories from the URL's provided and update itself at midnight.
- If you want to you can add repositories in yourself by raising a PR from main, add your repositories to the production-repos.json. Then merge the PR once ready.
To add or remove repositories follow the below:
- Open a fresh PR from the master branch ensuring you have pulled down recent changes to the master branch.
- Applies standardised rule sets to repositories listed in the
production-repos.json
file, ensuring consistent management and configuration across all repositories. - Create a PR and allow the GH Actions pipeline to run a Terraform Plan to confirm changes are accepted.
- Once the plan is good, you can merge your PR into main branch and the pipeline will trigger an apply.
- Once applied delete your branch.
- Check your Terraform version and ensure there are no underlying bugs with the provider versions.
- Ensure you have formatted your repository name correctly as it may not pick it up properly.
Name | Version |
---|---|
terraform | >= 1.5.7 |
github | ~> 6.0 |
Name | Version |
---|---|
azurerm | n/a |
github | ~> 6.0 |
local | n/a |
Name | Source | Version |
---|---|---|
tags | git::https://github.com/hmcts/terraform-module-common-tags.git | master |
Name | Type |
---|---|
azurerm_resource_group.rg | resource |
azurerm_storage_account.sa | resource |
azurerm_storage_container.tfstate | resource |
github_organization_ruleset.default_ruleset | resource |
github_team.admin | data source |
local_file.repos_json | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
builtFrom | Information about the build source or version | string |
"https://github.com/hmcts/github-repository-rules" |
no |
env | The environment for the deployment (e.g., dev, staging, prod) | string |
"dev" |
no |
location | The location for the resources | string |
"UK South" |
no |
oauth_token | OAUTH token to use for authentication. | string |
n/a | yes |
override_action | The action to override | string |
"plan" |
no |
product | The product name or identifier | string |
"sds-platform" |
no |
resource_group_name | The name of the resource group | string |
"rule-set-rg" |
no |
storage_account_name | The name of the storage account | string |
"rulesetsa" |
no |
Name | Description |
---|---|
common_tags | n/a |