From e7684185a9d1f584ce841dbc30f1086d2a013551 Mon Sep 17 00:00:00 2001 From: David Arnold <10138997+djaboxx@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:15:05 -0700 Subject: [PATCH 1/5] Update github_branch.tf --- github_branch.tf | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/github_branch.tf b/github_branch.tf index db022d7..642037a 100644 --- a/github_branch.tf +++ b/github_branch.tf @@ -52,11 +52,10 @@ resource "github_branch_protection" "main" { } dynamic "required_status_checks" { - # A bogus map for a conditional block - for_each = length(var.required_status_checks) > 0 ? ["*"] : [] + for_each = var.required_status_checks == null ? [] : ["*"] content { - contexts = var.required_status_checks - strict = true + contexts = required_status_checks.value.contexts + strict = required_status_checks.value.strict } } From e6a8606bcc775586e6169eecb513c1865e58877f Mon Sep 17 00:00:00 2001 From: David Arnold <10138997+djaboxx@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:18:01 -0700 Subject: [PATCH 2/5] Update variables.tf --- variables.tf | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/variables.tf b/variables.tf index 6a2f959..a005bfe 100644 --- a/variables.tf +++ b/variables.tf @@ -108,11 +108,25 @@ variable "admin_teams" { default = [] } - +# Required Status Checks +# required_status_checks supports the following arguments: +# strict: (Optional) Require branches to be up to date before merging. Defaults to false. +# contexts: (Optional) The list of status checks to require in order to merge into this branch. +# No status checks are required by default. +# Note: This attribute can contain multiple string patterns. If specified, usual value is the job name. +# Otherwise, the job id is defaulted to. For workflows that use matrixes, append the matrix name to the +# value using the following pattern ([, ]). Matrixes should be specified +# based on the order of matrix properties in the workflow file. See GitHub Documentation for more +# information. For workflows that use reusable workflows, +# the pattern is / . +# This can extend multiple levels. variable "required_status_checks" { description = "Required Status Checks" - type = list(any) - default = [] + type = object({ + contexts = list(string) + strict = optional(bool, true) + }) + default = null } variable "archived" { From bbfab25a1713016ee9812dc6af93765eea71295c Mon Sep 17 00:00:00 2001 From: David Arnold <10138997+djaboxx@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:18:54 -0700 Subject: [PATCH 3/5] Update variables.tf --- variables.tf | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/variables.tf b/variables.tf index a005bfe..f5c797f 100644 --- a/variables.tf +++ b/variables.tf @@ -108,20 +108,23 @@ variable "admin_teams" { default = [] } -# Required Status Checks -# required_status_checks supports the following arguments: -# strict: (Optional) Require branches to be up to date before merging. Defaults to false. -# contexts: (Optional) The list of status checks to require in order to merge into this branch. -# No status checks are required by default. -# Note: This attribute can contain multiple string patterns. If specified, usual value is the job name. -# Otherwise, the job id is defaulted to. For workflows that use matrixes, append the matrix name to the -# value using the following pattern ([, ]). Matrixes should be specified -# based on the order of matrix properties in the workflow file. See GitHub Documentation for more -# information. For workflows that use reusable workflows, -# the pattern is / . -# This can extend multiple levels. + variable "required_status_checks" { - description = "Required Status Checks" + description = <[, ]). Matrixes should be specified +based on the order of matrix properties in the workflow file. See GitHub Documentation for more +information. For workflows that use reusable workflows, +the pattern is / . +This can extend multiple levels. +EOT type = object({ contexts = list(string) strict = optional(bool, true) From 43aa05effa5e6d593d4d3c81c115f07894df43d8 Mon Sep 17 00:00:00 2001 From: David Arnold <10138997+djaboxx@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:19:26 -0700 Subject: [PATCH 4/5] Update variables.tf --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index f5c797f..0523e85 100644 --- a/variables.tf +++ b/variables.tf @@ -127,7 +127,7 @@ This can extend multiple levels. EOT type = object({ contexts = list(string) - strict = optional(bool, true) + strict = optional(bool, false) }) default = null } From 73edcf4d3b5dfddc734257cd8be29be3a1eadc9d Mon Sep 17 00:00:00 2001 From: Dave Arnold Date: Wed, 21 Aug 2024 16:51:53 -0700 Subject: [PATCH 5/5] chore: Update Terraform provider version for GitHub to >= 6.2.3 --- .github/workflows/terraform.yml | 17 +++++++++++++++++ github_repo.tf | 3 ++- variables.tf | 10 ++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/terraform.yml diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml new file mode 100644 index 0000000..bf78fd0 --- /dev/null +++ b/.github/workflows/terraform.yml @@ -0,0 +1,17 @@ +name: "Terraform" + +on: + workflow_dispatch: + pull_request: + +jobs: + terraform: + uses: HappyPathway/centralized-actions/.github/workflows/terraform.yml@main + with: + terraform_version: 1.9.1 + terraform_api: app.terraform.io + github_username: djaboxx + github_email: git@roknsound.com + secrets: + TFE_TOKEN: ${{ secrets.TFE_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/github_repo.tf b/github_repo.tf index 85f372d..4e542bd 100644 --- a/github_repo.tf +++ b/github_repo.tf @@ -2,6 +2,7 @@ locals { repo_name = var.force_name ? var.name : "${var.name}-${formatdate("YYYYMMDD", timestamp())}" } + resource "github_repository" "repo" { name = local.repo_name description = var.github_repo_description @@ -10,7 +11,7 @@ resource "github_repository" "repo" { allow_merge_commit = var.github_allow_merge_commit allow_squash_merge = var.github_allow_squash_merge allow_rebase_merge = var.github_allow_rebase_merge - archive_on_destroy = true + archive_on_destroy = var.archive_on_destroy delete_branch_on_merge = var.github_delete_branch_on_merge has_projects = var.github_has_projects has_issues = var.github_has_issues diff --git a/variables.tf b/variables.tf index 0523e85..cf78f8e 100644 --- a/variables.tf +++ b/variables.tf @@ -125,11 +125,11 @@ information. For workflows that use reusable workflows, the pattern is / . This can extend multiple levels. EOT - type = object({ + type = object({ contexts = list(string) strict = optional(bool, false) }) - default = null + default = null } variable "archived" { @@ -192,3 +192,9 @@ variable "collaborators" { description = "list of repo callaborators" default = {} } + + +variable "archive_on_destroy" { + type = bool + default = true +}