Skip to content

Commit 9102704

Browse files
committed
Try tflint
1 parent 7894cb9 commit 9102704

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

.github/workflows/tflint.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: TFLint
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
#tf_token_keeper_path:
7+
# required: true
8+
# type: string
9+
parent_tf_dir:
10+
required: true
11+
type: string
12+
description: Parent directory where all Terraform files are underneath
13+
default: "."
14+
cli_opts:
15+
required: false
16+
type: string
17+
default: " "
18+
secrets:
19+
github_token:
20+
required: true
21+
22+
jobs:
23+
terraform_fmt:
24+
runs-on: self-hosted
25+
container:
26+
image: buildpack-deps:bookworm
27+
steps:
28+
- uses: actions/checkout@v4
29+
name: Checkout source code
30+
31+
- name: Calculate tflint config hash
32+
id: hash
33+
run: |
34+
echo "hash=$(sha256sum ${{ inputs.parent_tf_dir }}/.tflint.hcl | cut -d' ' -f1)" >> $GITHUB_OUTPUT
35+
36+
- uses: actions/cache@v4
37+
name: Cache plugin dir
38+
with:
39+
path: ~/.tflint.d/plugins
40+
key: selfhosted-tflint-${{ steps.hash.outputs.hash }}
41+
42+
- uses: terraform-linters/setup-tflint@v4
43+
name: Setup TFLint
44+
with:
45+
tflint_version: latest
46+
47+
- name: Show version
48+
run: |
49+
cd ${{ inputs.parent_tf_dir }}
50+
tflint --version
51+
52+
- name: Init TFLint
53+
run: |
54+
cd ${{ inputs.parent_tf_dir }}
55+
tflint --init
56+
env:
57+
# https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting
58+
GITHUB_TOKEN: ${{ secrets.github_token }}
59+
60+
- name: Run TFLint recursively
61+
run: |
62+
cd ${{ inputs.parent_tf_dir }}
63+
tflint --recursive -f compact ${{ inputs.cli_opts }}

0 commit comments

Comments
 (0)