Skip to content

Commit

Permalink
Enhance GitHub environment configuration by using team slugs and user…
Browse files Browse the repository at this point in the history
…names for reviewer IDs, and update default commit email for consistency
  • Loading branch information
Dave Arnold committed Feb 20, 2025
1 parent 7f0ddaa commit a991ab8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions environment.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
data "github_team" "environment_teams" {
for_each = toset(flatten([
for env in var.environments :
try(coalesce(env.reviewers.teams, []), [])
]))
slug = each.value # Look up teams by slug (name) instead of ID
}

data "github_user" "environment_users" {
for_each = toset(flatten([
for env in var.environments :
try(coalesce(env.reviewers.users, []), [])
]))
username = each.value
}

resource "github_repository_environment" "environments" {
for_each = { for env in var.environments : env.name => env }

environment = each.value.name
repository = github_repository.repo[0].name
reviewers {
teams = try(each.value.reviewers.teams, [])
users = try(each.value.reviewers.users, [])
teams = [for team_slug in try(each.value.reviewers.teams, []) : data.github_team.environment_teams[team_slug].id]
users = [for username in try(each.value.reviewers.users, []) : data.github_user.environment_users[username].id]
}
deployment_branch_policy {
protected_branches = try(each.value.deployment_branch_policy.protected_branches, true)
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ variable "commit_author" {
variable "commit_email" {
description = "The email to use for file commits"
type = string
default = "terraform@example.com"
default = "terraform@roknsound.com"
}

variable "require_signed_commits" {
Expand Down

0 comments on commit a991ab8

Please sign in to comment.