action-tflint
GitHub Action that will run TFlint on Terraform files
100K+
GitHub Action that will run TFlint on Terraform files.
This action supports three tag levels for flexible versioning:
vX: latest patch of the major version (e.g., v1).vX.Y: latest patch of the minor version (e.g., v1.2).vX.Y.Z: fixed to a specific release (e.g., v1.2.3). - name: Run the Action
uses: devops-infra/[email protected]
with:
dir_filter: modules
| Input Variable | Required | Default | Description |
|---|---|---|---|
dir_filter | No | * | Prefixes or sub-directories to search for Terraform modules. Use comma as separator. |
fail_on_changes | No | true | Whether TFLint should fail whole action. |
tflint_config | No | .tflint.hcl | Location from repository root to TFLint config file. Disables tflint_params. |
tflint_params | No | `` | Parameters passed to TFLint binary. See TFLintโ for details. |
run_init | No | true | Whether the action should run terraform init. Defaults to true. |
By default fail if lint errors found in any subdirectory. Run the Action via GitHub.
name: Check TFLint
on:
push:
branches:
- "**"
jobs:
format-hcl:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Check linting of Terraform files
uses: devops-infra/[email protected]
Use different location for TFLint config file and parse only aws* and gcp* modules in modules/ directory. Run the Action via GitHub.
name: Check TFLint with custom config
on:
push:
branches:
- "**"
jobs:
format-hcl:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Check linting of Terraform modules
uses: devops-infra/[email protected]
with:
tflint_config: modules/.tflint.hcl
dir_filter: modules/aws,modules/gcp
Use deep check (need cloud credentials) and treat all directories under modules as Terraform modules. Run the Action via DockerHub.
name: Check TFLint with custom config
on:
push:
branches:
- "**"
jobs:
format-hcl:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Check linting of Terraform modules
uses: devops-infra/[email protected]
with:
tflint_params: "--module --deep"
dir_filter: modules
Pick the tag level based on your stability needs:
vX.Y.Z: exact immutable release (most predictable)vX.Y: latest patch within one minor linevX: latest patch within one major linename: Use pinned action version
on: [push]
jobs:
tflint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: devops-infra/[email protected]
id: pin-patch
- uses: devops-infra/[email protected]
id: pin-minor
- uses: devops-infra/action-tflint@v1
id: pin-major
Contributions are welcome! See CONTRIBUTINGโ . This project is licensed under the MIT License - see the LICENSEโ file for details.
This project is licensed under the MIT License - see the LICENSEโ file for details.
If you have any questions or need help, please:
Use the manual workflow .github/workflows/manual-e2e-validate.yml to validate this action against the centralized E2E repository.
mode=image validates a published image tag (recommended for -test and -rc release checks).mode=ref validates ref-oriented E2E paths against stable pinned action refs.CI/CD automation also runs these E2E checks automatically:
-rc).Example trigger inputs:
mode=ref
mode=image
image_tag=v1.2.3-test
To publish images from a fork, set these variables so Task uses your registry identities:
DOCKER_USERNAME, DOCKER_ORG_NAME, GITHUB_USERNAME, GITHUB_ORG_NAME.
Two supported options (environment variables take precedence over .env):
# .env (local only, not committed)
DOCKER_USERNAME=your-dockerhub-user
DOCKER_ORG_NAME=your-dockerhub-org
GITHUB_USERNAME=your-github-user
GITHUB_ORG_NAME=your-github-org
# Shell override
DOCKER_USERNAME=your-dockerhub-user \
DOCKER_ORG_NAME=your-dockerhub-org \
GITHUB_USERNAME=your-github-user \
GITHUB_ORG_NAME=your-github-org \
task docker:build
Recommended setup:
.env file.DOCKER_TOKEN and GITHUB_TOKEN.Publish images without a release:
(Manual) Release Create workflow with build_only: true to build and push images without tagging a release.Content type
Image
Digest
sha256:34044712cโฆ
Size
68.4 MB
Last updated
4 days ago
docker pull devopsinfra/action-tflint:latest-testPulls:
1,772
Last week