Skip to content

Commit

Permalink
Merge pull request #2 from HappyPathway/pr_checks
Browse files Browse the repository at this point in the history
Update github_branch.tf
  • Loading branch information
David Arnold authored and GitHub committed Aug 21, 2024
2 parents 6304343 + 73edcf4 commit 010edcb
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -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 }}
7 changes: 3 additions & 4 deletions github_branch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
3 changes: 2 additions & 1 deletion github_repo.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
29 changes: 26 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,26 @@ variable "admin_teams" {


variable "required_status_checks" {
description = "Required Status Checks"
type = list(any)
default = []
description = <<EOT
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 (<matrix_value>[, <matrix_value>]). 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 <initial_workflow.jobs.job.[name/id]> / <reused-workflow.jobs.job.[name/id]>.
This can extend multiple levels.
EOT
type = object({
contexts = list(string)
strict = optional(bool, false)
})
default = null
}

variable "archived" {
Expand Down Expand Up @@ -175,3 +192,9 @@ variable "collaborators" {
description = "list of repo callaborators"
default = {}
}


variable "archive_on_destroy" {
type = bool
default = true
}

0 comments on commit 010edcb

Please sign in to comment.