From 5f0379ed3400804335cc08010204082b19b6da63 Mon Sep 17 00:00:00 2001 From: nolte Date: Sat, 20 May 2023 22:40:17 +0200 Subject: [PATCH] add terraform linter (#170) --- .github/workflows/reuseable-tf-lint.yaml | 46 ++++++++++++++++++++++++ README.md | 1 + 2 files changed, 47 insertions(+) create mode 100644 .github/workflows/reuseable-tf-lint.yaml diff --git a/.github/workflows/reuseable-tf-lint.yaml b/.github/workflows/reuseable-tf-lint.yaml new file mode 100644 index 0000000..73bc2a7 --- /dev/null +++ b/.github/workflows/reuseable-tf-lint.yaml @@ -0,0 +1,46 @@ +name: tf-lint + +on: + workflow_call: + secrets: + token: + required: true + +permissions: + contents: write + pull-requests: write + +jobs: + tflint: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + + steps: + - uses: actions/checkout@v3 + name: Checkout source code + + - uses: actions/cache@v3 + name: Cache plugin dir + with: + path: ~/.tflint.d/plugins + key: ${{ matrix.os }}-tflint-${{ hashFiles('.tflint.hcl') }} + + - uses: terraform-linters/setup-tflint@v3 + name: Setup TFLint + with: + tflint_version: v0.44.1 + + - name: Show version + run: tflint --version + + - name: Init TFLint + run: tflint --init + env: + # https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting + GITHUB_TOKEN: ${{ secrets.token }} + + - name: Run TFLint + run: tflint -f compact diff --git a/README.md b/README.md index db96c45..419859e 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Used for deduplicate the CI/CD Boilerplate-Code. Like [Workflow](https://docs.gi | ```reuseable-sphinx.yaml``` | Build and Publish a [Sphinx](https://www.sphinx-doc.org/en/master) Documentation as [Github Page](https://pages.github.com/). | | ```reuseable-stale.yaml``` | Mark old or inactive issues and close then, used [actions/stale](https://github.com/actions/stale) for this work. | | ```reuseable-trivy.yaml``` | Scan the GitRepo by using [aquasecurity/trivy-action](https://github.com/aquasecurity/trivy-action). | +| ```reuseable-tf-lint.yaml``` | Use [terraform-linters/setup-tflint](https://github.com/terraform-linters/setup-tflint) for Lint terraform sources. | ## Probot Config