-
Notifications
You must be signed in to change notification settings - Fork 73
70 lines (65 loc) · 1.94 KB
/
lint.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: lint
on:
workflow_dispatch:
inputs:
ref:
description: The branch, tag or SHA to checkout
default: main
type: string
push:
branches:
- main
paths-ignore:
- ".git**"
pull_request:
jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0
env:
SHELLCHECK_OPTS: -e SC2086 -e SC1117
terraform-fmt:
name: terraform fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/cache@v3
with:
path: ~/tfenv
key: tfenv-${{ runner.os }}
- name: Validate JSON
run: find . -type -f -name '*.json' | xargs tools/json-check.sh
- name: terraform install
env:
TFENV_VERSION: '3.0.0'
run: |
echo "Installing tfenv."
mkdir -p tfenv
curl -L --silent --fail \
"https://github.com/tfutils/tfenv/archive/refs/tags/v${TFENV_VERSION}.tar.gz" \
| tar -zxf - --strip-components=1 -C tfenv
export PATH="$PATH:$PWD/tfenv/bin"
echo "Installing default Terraform version."
tfenv install
tfenv use
echo "Installing other necessary Terraform versions."
for version in $(find terraform/ -type f -name '.terraform-version' | xargs sort -u); do
tfenv install "$version"
done
- name: terraform fmt
run: |
find terraform/ \
-type f -name main.tf -not -path "*.terraform*" \
-execdir "$PWD/tfenv/bin/terraform" fmt -recursive . \;
if ! git diff --exit-code; then
echo "Run terraform fmt -recursive . to fix formatting."
exit 1
fi