Terraform/GitHub repository rulesets #13596
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new, modular Terraform setup for managing GitHub repository rulesets in production. The changes enable defining rulesets as variables and applying them to multiple repositories in a scalable and reusable way, using modules and submodules.
Key changes:
1. Infrastructure as Code Improvements
repository_namesand complexrulesetsingithub-repositories-ruleset-variables.tf, allowing flexible configuration of which repositories receive which rulesets and how those rulesets are defined.github-repositories-ruleset.tfto apply the rulesets to each repository listed inrepository_names.2. Module Structure and Reusability
github-repositorymodule, which takes a repository name and a list of rulesets, and delegates to arulesetsubmodule for each ruleset. [1] [2]3. Ruleset Resource Management
github_repository_rulesetresource in therulesetsubmodule, supporting a wide range of rules (branch protection, pull request, status checks, merge queue, etc.) and conditions, with dynamic blocks for optional features.These changes make it much easier to manage and scale repository rules across multiple GitHub repositories in a consistent, DRY (Don't Repeat Yourself) manner.