From 3badfcb83805cccdd748700e06672266859b36f9 Mon Sep 17 00:00:00 2001 From: Andreas Sommer Date: Wed, 18 Dec 2024 16:27:04 +0100 Subject: [PATCH] Validate/format Tofu code --- .github/workflows/tofu-checks.yaml | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/tofu-checks.yaml diff --git a/.github/workflows/tofu-checks.yaml b/.github/workflows/tofu-checks.yaml new file mode 100644 index 0000000..9937025 --- /dev/null +++ b/.github/workflows/tofu-checks.yaml @@ -0,0 +1,33 @@ +name: OpenTofu checks +on: + push: + +jobs: + tofu_checks: + name: OpenTofu checks + runs-on: ubuntu-24.04 + steps: + - uses: opentofu/setup-opentofu@592200bd4b9bbf4772ace78f887668b1aee8f716 # v1.0.5 + with: + tofu_version: 1.8.7 + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Checks + run: | + set -eu + + for d in admin-role capa-controller-role; do ( + cd "${d}" + + echo "Initializing Tofu for ${d}" + tofu init + + echo "Validating Tofu code for ${d}" + tofu validate -no-color + + echo "Formatting Tofu code for ${d}" + tofu fmt + echo "Checking differences in Tofu code formatting for ${d}" + git diff --exit-code || { >&2 echo "Tofu code isn't formatted, please run 'tofu fmt'"; exit 1; } + ); done