diff --git a/github_files.tf b/github_files.tf index 38c3e10..51888d0 100644 --- a/github_files.tf +++ b/github_files.tf @@ -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 }) @@ -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 @@ -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