The full guide (including an explanation of the snippets) is available via operatehappy.com/managing-github-repositories-with-terraform.
Last active
August 16, 2019 15:24
-
-
Save operatehappy-bot/6a05c155f560946e30de92bfd0eb5d30 to your computer and use it in GitHub Desktop.
Managing GitHub Repositories with Terraform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
required_pull_request_reviews { | |
dismiss_stale_reviews = true | |
dismissal_teams = [github_team.internal.slug] | |
required_approving_review_count = floor((length(var.internal_team_members) / 2)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "github_branch_protection" "monitoring-app" { | |
repository = github_repository.monitoring-app.name | |
branch = "master" | |
enforce_admins = true | |
require_signed_commits = true | |
required_status_checks { | |
strict = true | |
contexts = ["ci/enforcer"] | |
} | |
required_pull_request_reviews { | |
dismiss_stale_reviews = true | |
dismissal_teams = [github_team.internal.slug] | |
} | |
restrictions { | |
teams = [github_team.internal.slug] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remove the `monitoring-app` resource from Terraform's State | |
terraform state rm github_repository.monitoring-app | |
# import the `monitoring-app` resource into Terraform's State | |
terraform import github_repository.monitoring-app monitoring-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "github_repository" "monitoring-app" { | |
name = "monitoring-app" | |
description = "Operate Happy's monitoring app" | |
homepage_url = "https://operatehappy.com/monitoring-app" | |
private = false | |
has_downloads = false | |
has_issues = true | |
has_projects = false | |
has_wiki = false | |
allow_merge_commit = false | |
allow_rebase_merge = false | |
allow_squash_merge = true | |
auto_init = false | |
topics = [ | |
"application", | |
"monitoring" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "github_team_repository" "monitoring-app" { | |
team_id = "${github_team.internal.id}" | |
repository = "${github_repository.monitoring-app.name}" | |
permission = "push" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment