Skip to content

Commit 0de9c23

Browse files
Add tf-check (#7)
* Add `tf-check` * Update README * Add flag to execute recursively * Removing flags for `diff`s * Better messages --------- Co-authored-by: Pedro Rodrigues <hpedrorodrigues@users.noreply.github.com>
1 parent 7f7b426 commit 0de9c23

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- [envsubst](./envsubst)
44
- [kustomize](./kustomize)
55
- [setup-sphynx](./setup-sphynx)
6+
- [tf-check](./tf-check)
67

78
## Release
89

tf-check/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM ghcr.io/hpedrorodrigues/tf
2+
COPY entrypoint.sh /
3+
ENTRYPOINT ["/entrypoint.sh"]

tf-check/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# tf-check
2+
3+
Checks files recursively against a canonical format using [Terraform][terraform], [OpenTofu][opentofu] and [Terragrunt][terragrunt].
4+
5+
## Usage
6+
7+
```yaml
8+
- name: Lint
9+
uses: hpedrorodrigues/actions/tf-check@v1.0.3
10+
```
11+
12+
[terraform]: https://www.terraform.io
13+
[opentofu]: https://opentofu.org
14+
[terragrunt]: https://terragrunt.gruntwork.io

tf-check/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: tf-check
2+
author: Pedro Rodrigues
3+
description: Checks files recursively against a canonical format.
4+
branding:
5+
icon: activity
6+
color: gray-dark
7+
runs:
8+
using: docker
9+
image: Dockerfile

tf-check/entrypoint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
set -o errexit
4+
set -o nounset
5+
6+
if ${VERBOSE:-false}; then
7+
set -o xtrace
8+
fi
9+
10+
echo 'Checking Terraform files...'
11+
terraform fmt -check -recursive
12+
13+
echo 'Checking OpenTofu files...'
14+
tofu fmt -check -recursive
15+
16+
echo 'Checking Terragrunt files...'
17+
terragrunt hclfmt --terragrunt-check

0 commit comments

Comments
 (0)