From a991ab89a7b6ba9ac7ac603ecc94e178accc7f74 Mon Sep 17 00:00:00 2001 From: Dave Arnold Date: Wed, 19 Feb 2025 22:52:15 -0800 Subject: [PATCH] Enhance GitHub environment configuration by using team slugs and usernames for reviewer IDs, and update default commit email for consistency --- environment.tf | 20 ++++++++++++++++++-- variables.tf | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/environment.tf b/environment.tf index 2a43c81..314957d 100644 --- a/environment.tf +++ b/environment.tf @@ -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) diff --git a/variables.tf b/variables.tf index 3ac9702..9b14db8 100644 --- a/variables.tf +++ b/variables.tf @@ -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" {