GitHub Repository Factory
This module provides a standardized way to create and configure GitHub repositories with common settings, including branch protections, environment secrets, and automated initialization.
Usage
See the examples/ directory for deployable examples.
Example: Branch Protection
This example shows how to enable branch protection on the main branch, requiring at least one approving pull request review before merging.
module "github_repository" {
source = "github.com/GITHUB_ORG/TF_MODULE_REPO//github-repository-factory"
repo_owner = "my-org"
repo_name = "my-awesome-repo"
repo_description = "A repository with branch protection"
repo_prefix = "infra"
create_repository = true
branch_protections = {
main = {
enforce_admins = true
required_pull_request_reviews = {
required_approving_review_count = 1
dismiss_stale_reviews = true
}
}
}
}