From def41c71b9660e58cd4a59fa2e082c6dfb9205c6 Mon Sep 17 00:00:00 2001 From: velotioaastha Date: Wed, 4 Sep 2024 14:28:17 +0530 Subject: [PATCH] Configure tflint and tf format --- .github/workflows/pr-tflint-fmt.yml | 25 ---------------------- .github/workflows/tf-lint.yaml | 33 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 25 deletions(-) delete mode 100644 .github/workflows/pr-tflint-fmt.yml create mode 100644 .github/workflows/tf-lint.yaml diff --git a/.github/workflows/pr-tflint-fmt.yml b/.github/workflows/pr-tflint-fmt.yml deleted file mode 100644 index 79c5058..0000000 --- a/.github/workflows/pr-tflint-fmt.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Tflint Checks on Terraform Code -on: - pull_request: -jobs: - tflint-checks: - runs-on: ubuntu-latest - steps: - - name : Clone repo - uses: actions/checkout@master - - uses: actions/cache@v2 - name: Cache plugin dir - with: - path: ~/.tflint.d/plugins - key: ${{ matrix.os }}-tflint-${{ hashFiles('.tflint.hcl') }} - - uses: terraform-linters/setup-tflint@v2 - name: Setup TFLint - with: - github_token: ${{ github.token }} - - name: Show version - run: tflint --version - - name: Init TFLint - run: tflint --init -# Run tflint command in each directory recursively # use --force if you want to continue with workflow although errors are there - - name: Run TFLint - run: tflint -f compact --recursive \ No newline at end of file diff --git a/.github/workflows/tf-lint.yaml b/.github/workflows/tf-lint.yaml new file mode 100644 index 0000000..b0e784e --- /dev/null +++ b/.github/workflows/tf-lint.yaml @@ -0,0 +1,33 @@ +name: Terraform Lint and Format Check + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + terraform_checks: + name: Run Terraform Lint and Format Check + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v1 + with: + terraform_version: "~1" + + - name: Install tflint + run: | + curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash + + - name: Run tflint + run: tflint + + - name: Check Terraform formatting + run: terraform fmt -check -recursive