From 74486a084a8289c0df874ef18f7f903107699c3f Mon Sep 17 00:00:00 2001 From: Vedant Pareek Date: Tue, 22 Oct 2024 18:38:46 +0530 Subject: [PATCH] Added workflows --- .github/workflows/lint_clean.yaml | 18 ++++++++++++ .github/workflows/terraform-docs.yaml | 16 +++++++++++ .github/workflows/tflint.yaml | 40 +++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 .github/workflows/lint_clean.yaml create mode 100644 .github/workflows/terraform-docs.yaml create mode 100644 .github/workflows/tflint.yaml diff --git a/.github/workflows/lint_clean.yaml b/.github/workflows/lint_clean.yaml new file mode 100644 index 0000000..a15b694 --- /dev/null +++ b/.github/workflows/lint_clean.yaml @@ -0,0 +1,18 @@ +name: 'Lint and Clean' + +on: + pull_request: + + push: + branches: + - main + +jobs: + fmt: + name: Terraform FMT + runs-on: ubuntu-latest + container: + image: hashicorp/terraform:latest + steps: + - uses: actions/checkout@v2 + - run: terraform fmt --recursive --diff -check=true \ No newline at end of file diff --git a/.github/workflows/terraform-docs.yaml b/.github/workflows/terraform-docs.yaml new file mode 100644 index 0000000..5c766b9 --- /dev/null +++ b/.github/workflows/terraform-docs.yaml @@ -0,0 +1,16 @@ +name: Generate terraform docs +on: + - pull_request + +jobs: + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.ref }} + + - name: Render terraform docs and push changes back to PR + uses: terraform-docs/gh-actions@main + with: + git-push: "true" \ No newline at end of file diff --git a/.github/workflows/tflint.yaml b/.github/workflows/tflint.yaml new file mode 100644 index 0000000..42620cf --- /dev/null +++ b/.github/workflows/tflint.yaml @@ -0,0 +1,40 @@ +name: Lint +on: + pull_request: + branches: + - main + +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.47.0 + + - 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: ${{ github.token }} + + - name: Run TFLint + run: tflint --minimum-failure-severity=error -f compact \ No newline at end of file