From 576de74d567d167751efbce72b4f93104f7813df Mon Sep 17 00:00:00 2001 From: Jakub Burghardt Date: Thu, 30 Nov 2023 10:28:14 +0100 Subject: [PATCH] add terraform format job --- .github/workflows/terraform-fmt.yml | 22 ++++++++++++++++++++++ Makefile | 4 ++++ 2 files changed, 26 insertions(+) create mode 100644 .github/workflows/terraform-fmt.yml diff --git a/.github/workflows/terraform-fmt.yml b/.github/workflows/terraform-fmt.yml new file mode 100644 index 00000000..d27a0629 --- /dev/null +++ b/.github/workflows/terraform-fmt.yml @@ -0,0 +1,22 @@ +name: Terraform format +on: + pull_request: +jobs: + terraform_fmt: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Terraform + uses: hashicorp/setup-terraform@v2 + + - name: Terraform format + run: | + make format-tf + if [[ -n $(git status -s) ]] + then + echo "Terraform code is not formatted, format it by running 'make format-tf' and commit your changes." + exit 1 + fi + diff --git a/Makefile b/Makefile index 84c92a31..6d5a9578 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,10 @@ init-examples: done \ done +.PHONY: format-tf +format-tf: + terraform fmt -recursive -list=false + .PHONY: generate-sdk generate-sdk: @echo "==> Generating castai sdk client"