Skip to content

Commit

Permalink
Refactor repository references in action_secrets.tf and github_files.…
Browse files Browse the repository at this point in the history
…tf to use local.github_repo for improved clarity and consistency
  • Loading branch information
Dave Arnold committed Feb 19, 2025
1 parent 91a11df commit d0c2036
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions action_secrets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ locals {

resource "github_actions_secret" "secret" {
for_each = tomap({ for secret in var.secrets : secret.name => secret.value })
repository = local.repo_exists.name
repository = local.github_repo.name
secret_name = each.key
plaintext_value = each.value
depends_on = [local.repo_exists]
depends_on = [local.github_repo]
}

resource "github_actions_variable" "variable" {
for_each = tomap({ for _var in var.vars : _var.name => _var.value })
repository = local.repo_exists.name
repository = local.github_repo.name
variable_name = each.key
value = each.value
depends_on = [local.repo_exists]
depends_on = [local.github_repo]
}
8 changes: 4 additions & 4 deletions github_files.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
locals {
# Process files only if commit signing is not required or if explicitly allowed
should_manage_files = !try(local.repo_exists.require_signed_commits, false) || var.allow_unsigned_files
should_manage_files = !try(local.github_repo.require_signed_commits, false) || var.allow_unsigned_files
}

# https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_file
resource "github_repository_file" "codeowners" {
count = var.create_codeowners && local.should_manage_files ? 1 : 0

repository = local.repo_exists.name
repository = local.github_repo.name
branch = var.github_default_branch
file = "CODEOWNERS"
content = templatefile("${path.module}/templates/CODEOWNERS", { codeowners = local.codeowners })
Expand Down Expand Up @@ -52,7 +52,7 @@ locals {
resource "github_repository_file" "extra_files" {
for_each = local.should_manage_files ? tomap({ for file in local.extra_files : "${element(split("/", file.path), length(split("/", file.path)) - 1)}" => file }) : {}

repository = local.repo_exists.name
repository = local.github_repo.name
branch = var.github_default_branch
file = each.value.path
content = each.value.content
Expand All @@ -72,7 +72,7 @@ resource "github_repository_file" "extra_files" {
resource "github_repository_file" "managed_extra_files" {
for_each = local.should_manage_files ? tomap({ for file in var.managed_extra_files : "${element(split("/", file.path), length(split("/", file.path)) - 1)}" => file }) : {}

repository = local.repo_exists.name
repository = local.github_repo.name
branch = var.github_default_branch
file = each.value.path
content = each.value.content
Expand Down

0 comments on commit d0c2036

Please sign in to comment.