-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (83 loc) · 2.35 KB
/
ci.yml
File metadata and controls
99 lines (83 loc) · 2.35 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: "🔧 Terraform CI"
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pull-requests: write
jobs:
terraform-fmt:
name: "📐 Format Check"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ">=1.5.0"
- name: Terraform Format Check
run: terraform fmt -check -recursive -diff
terraform-validate:
name: "✅ Validate"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ">=1.5.0"
- name: Terraform Init
run: terraform init -backend=false
- name: Terraform Validate
run: terraform validate
tflint:
name: "🔍 TFLint"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup TFLint
uses: terraform-linters/setup-tflint@v4
with:
tflint_version: latest
- name: Init TFLint
run: tflint --init
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Run TFLint
run: tflint --recursive --format compact --minimum-failure-severity=error
terraform-plan:
name: "📋 Plan (Validation)"
runs-on: ubuntu-latest
needs: [terraform-fmt, terraform-validate]
if: success()
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ">=1.5.0"
- name: Find and Validate Examples
run: |
if [ -d "examples" ]; then
for dir in examples/*/; do
if [ -f "${dir}main.tf" ] || [ -f "${dir}versions.tf" ]; then
echo "::group::Validating ${dir}"
cd "${dir}"
terraform init -backend=false
terraform validate
cd - > /dev/null
echo "::endgroup::"
fi
done
else
echo "No examples directory found — validating root module"
terraform init -backend=false
terraform validate
fi