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_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 } } 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 6a2f959..cf78f8e 100644 --- a/variables.tf +++ b/variables.tf @@ -110,9 +110,26 @@ variable "admin_teams" { variable "required_status_checks" { - description = "Required Status Checks" - type = list(any) - default = [] + 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, false) + }) + default = null } variable "archived" { @@ -175,3 +192,9 @@ variable "collaborators" { description = "list of repo callaborators" default = {} } + + +variable "archive_on_destroy" { + type = bool + default = true +}