From f7e2f47b1cec839698f49a47a2bc5d13715a7121 Mon Sep 17 00:00:00 2001 From: waxb Date: Wed, 24 Apr 2024 15:34:43 +0200 Subject: [PATCH 1/2] demo: single fail dev --- .github/workflows/called.yaml | 2 +- imports/called.tm.hcl | 2 +- stacks/dev/file | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/called.yaml b/.github/workflows/called.yaml index 737d977..584cc65 100644 --- a/.github/workflows/called.yaml +++ b/.github/workflows/called.yaml @@ -11,7 +11,7 @@ "with": "fetch-depth": 0 - "name": "check for ${{ inputs.environment }}" - "run": "cat stacks/${{ inputs.environment }}/*" + "run": "[ ${{ inputs.environment }} != \"dev\" ]" "on": "workflow_call": "inputs": diff --git a/imports/called.tm.hcl b/imports/called.tm.hcl index b9b5510..32a5b25 100644 --- a/imports/called.tm.hcl +++ b/imports/called.tm.hcl @@ -30,7 +30,7 @@ globals "workflow" "called" { }, { name = "check for $${{ inputs.environment }}" - run = "cat stacks/$${{ inputs.environment }}/*" + run = "[ $${{ inputs.environment }} != \"dev\" ]" } ] } diff --git a/stacks/dev/file b/stacks/dev/file index 6e3ceb2..a308764 100644 --- a/stacks/dev/file +++ b/stacks/dev/file @@ -1 +1,2 @@ this is dev! +and it is doomed! From c3696eb186df7c49d5ea68f7eb4e1190e7ab53b7 Mon Sep 17 00:00:00 2001 From: waxb Date: Wed, 24 Apr 2024 16:15:10 +0200 Subject: [PATCH 2/2] fix: add `main` repository configuration --- .github/workflows/main.yaml | 2 +- globals.tm.hcl | 2 ++ imports/main.tm.hcl | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b538191..b49d6a9 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -37,7 +37,7 @@ - "id": "generate" "name": "generate matrix" "run": | - output="$(for i in dev staging prod ; do [[ -z $(git diff --name-only origin/main...HEAD | grep -E "stacks/${i}") ]] || echo $i ; done)" + output="$(for i in dev staging prod ; do [[ -z $(git diff --name-only origin/master...HEAD | grep -E "stacks/${i}") ]] || echo $i ; done)" [ -z "$output" ] || echo "matrix=[\""${output//[ ]/\", \"}"\"]" >> "$GITHUB_OUTPUT" "name": "main" "on": diff --git a/globals.tm.hcl b/globals.tm.hcl index f23a829..e07f0a5 100644 --- a/globals.tm.hcl +++ b/globals.tm.hcl @@ -10,6 +10,8 @@ globals "workflows" { } globals "repository" { + # my account is so old that the default branch was `master` + main = "master" # which environments to manage environments = ["dev", "staging", "prod"] # run workflows on all environments regardless of change diff --git a/imports/main.tm.hcl b/imports/main.tm.hcl index 07c0304..77c4850 100644 --- a/imports/main.tm.hcl +++ b/imports/main.tm.hcl @@ -35,7 +35,7 @@ globals "workflow" "main" { name = "generate matrix" id = "generate" run = <<-EOF - output="$(for i in ${tm_join(" ", global.repository.environments)} ; do [[ -z $(git diff --name-only origin/main...HEAD | grep -E "stacks/$${i}") ]] || echo $i ; done)" + output="$(for i in ${tm_join(" ", global.repository.environments)} ; do [[ -z $(git diff --name-only origin/${global.repository.main}...HEAD | grep -E "stacks/$${i}") ]] || echo $i ; done)" [ -z "$output" ] || echo "matrix=[\""$${output//[ ]/\", \"}"\"]" >> "$GITHUB_OUTPUT" EOF }