Skip to content

Commit

Permalink
Update repository reference in GitHub file resources to use local var…
Browse files Browse the repository at this point in the history
…iable
  • Loading branch information
Dave Arnold committed Feb 19, 2025
1 parent 6e5bc00 commit 03c31c9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions github_files.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_file
resource "github_repository_file" "codeowners" {
count = var.create_codeowners ? 1 : 0
repository = local.github_repo.name
repository = local.repository_name
branch = var.github_default_branch
file = "CODEOWNERS"
content = templatefile("${path.module}/templates/CODEOWNERS", { codeowners = local.codeowners })
Expand Down Expand Up @@ -40,11 +40,12 @@ locals {
}
]
)
repository_name = var.create_repo ? local.github_repo.name : var.name
}

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

resource "github_repository_file" "managed_extra_files" {
for_each = tomap({ for file in var.managed_extra_files : "${element(split("/", file.path), length(split("/", file.path)) - 1)}" => file })
repository = local.github_repo.name
repository = local.repository_name
branch = var.github_default_branch
file = each.value.path
content = each.value.content
Expand Down

0 comments on commit 03c31c9

Please sign in to comment.