-
Notifications
You must be signed in to change notification settings - Fork 14
46 lines (38 loc) · 1.1 KB
/
terraform.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
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
name: Check Terraform Module
on:
pull_request:
jobs:
check-terraform:
name: Check Terraform
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./terraform
outputs:
CHECK_STATUS: "${{ env.CHECK_STATUS }}"
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
- name: Initialize Terraform Module
id: init
run: terraform init
- name: Validate Terraform Module
id: validate
run: terraform validate -no-color
- name: Validate terraform fmt
run: |
set +e
echo "CHECK_STATUS=0" >> "$GITHUB_ENV"
terraform fmt -recursive -check
FMT_STATUS="$?"
if [[ "$FMT_STATUS" -ne 0 ]]; then
echo "❌ terraform fmt failed" >> "$GITHUB_STEP_SUMMARY"
echo "CHECK_STATUS=1" >> "$GITHUB_ENV"
fi
- name: Process check
if: always()
run: exit "$CHECK_STATUS"