From e4dab4475b521c13af00e0dc448faa026f5c1b24 Mon Sep 17 00:00:00 2001 From: arnol377 Date: Fri, 4 Apr 2025 18:17:38 -0400 Subject: [PATCH] fix: update dependencies in branch protection and uncomment repository data resources --- branch_protection.tf | 5 ++++- github_files.tf | 32 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/branch_protection.tf b/branch_protection.tf index 344bbd3..a60544c 100644 --- a/branch_protection.tf +++ b/branch_protection.tf @@ -52,6 +52,9 @@ resource "github_branch_protection" "protection" { depends_on = [ github_repository.repo, github_branch.branch, - github_branch_default.default_main_branch + github_branch_default.default_main_branch, + github_repository_files.extra_files, + github_repository_file.codeowners, + github_repository_file.managed_extra_files ] } \ No newline at end of file diff --git a/github_files.tf b/github_files.tf index e4dee3a..ebd4931 100644 --- a/github_files.tf +++ b/github_files.tf @@ -27,27 +27,27 @@ resource "github_repository_file" "codeowners" { } } -# data "github_repository" "template_repo" { -# count = var.template_repo == null && var.template_repo_org == var.repo_org ? 0 : 1 -# full_name = "${var.template_repo_org == null ? "" : var.template_repo_org}/${var.template_repo == null ? "" : var.template_repo}" -# } +data "github_repository" "template_repo" { + count = var.template_repo == null && var.template_repo_org == var.repo_org ? 0 : 1 + full_name = "${var.template_repo_org == null ? "" : var.template_repo_org}/${var.template_repo == null ? "" : var.template_repo}" +} -# data "github_ref" "ref" { -# count = var.template_repo == null && var.template_repo_org == var.repo_org ? 0 : 1 -# owner = var.template_repo_org -# repository = var.template_repo -# ref = "heads/${element(data.github_repository.template_repo, 0).default_branch}" -# } +data "github_ref" "ref" { + count = var.template_repo == null && var.template_repo_org == var.repo_org ? 0 : 1 + owner = var.template_repo_org + repository = var.template_repo + ref = "heads/${element(data.github_repository.template_repo, 0).default_branch}" +} locals { extra_files = concat( var.extra_files, - # var.template_repo == null && var.template_repo_org == var.repo_org ? [] : [ - # { - # path = ".TEMPLATE_SHA", - # content = data.github_ref.ref[0].sha - # } - # ] + var.template_repo == null && var.template_repo_org == var.repo_org ? [] : [ + { + path = ".TEMPLATE_SHA", + content = data.github_ref.ref[0].sha + } + ] ) repository_name = var.create_repo ? local.github_repo.name : var.name }