Skip to content

Commit 35c9b0a

Browse files
JoshLuedemanCopilot
andcommitted
🔧 Add CI workflow
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3c7c842 commit 35c9b0a

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: "🔧 Terraform CI"
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
jobs:
14+
terraform-fmt:
15+
name: "📐 Format Check"
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Terraform
22+
uses: hashicorp/setup-terraform@v3
23+
with:
24+
terraform_version: ">=1.5.0"
25+
26+
- name: Terraform Format Check
27+
run: terraform fmt -check -recursive -diff
28+
29+
terraform-validate:
30+
name: "✅ Validate"
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Setup Terraform
37+
uses: hashicorp/setup-terraform@v3
38+
with:
39+
terraform_version: ">=1.5.0"
40+
41+
- name: Terraform Init
42+
run: terraform init -backend=false
43+
44+
- name: Terraform Validate
45+
run: terraform validate
46+
47+
tflint:
48+
name: "🔍 TFLint"
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
54+
- name: Setup TFLint
55+
uses: terraform-linters/setup-tflint@v4
56+
with:
57+
tflint_version: latest
58+
59+
- name: Init TFLint
60+
run: tflint --init
61+
env:
62+
GITHUB_TOKEN: ${{ github.token }}
63+
64+
- name: Run TFLint
65+
run: tflint --recursive --format compact
66+
67+
terraform-plan:
68+
name: "📋 Plan (Validation)"
69+
runs-on: ubuntu-latest
70+
needs: [terraform-fmt, terraform-validate]
71+
steps:
72+
- name: Checkout
73+
uses: actions/checkout@v4
74+
75+
- name: Setup Terraform
76+
uses: hashicorp/setup-terraform@v3
77+
with:
78+
terraform_version: ">=1.5.0"
79+
80+
- name: Find and Validate Examples
81+
run: |
82+
if [ -d "examples" ]; then
83+
for dir in examples/*/; do
84+
if [ -f "${dir}main.tf" ] || [ -f "${dir}versions.tf" ]; then
85+
echo "::group::Validating ${dir}"
86+
cd "${dir}"
87+
terraform init -backend=false
88+
terraform validate
89+
cd - > /dev/null
90+
echo "::endgroup::"
91+
fi
92+
done
93+
else
94+
echo "No examples directory found — validating root module"
95+
terraform init -backend=false
96+
terraform validate
97+
fi

0 commit comments

Comments
 (0)