-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (42 loc) · 1.31 KB
/
validation.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
name: Terraform Validation
on:
push:
branches:
- main
pull_request:
jobs:
find-directories:
name: Find Terraform Directories
runs-on: ubuntu-latest
outputs:
directories: ${{ steps.get-dirs.outputs.dirs }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Find directories with Terraform projects
id: get-dirs
run: |
dirs=$(find . -type f -name "*.tf" -print0 | xargs -0 -n1 dirname | sort -u)
dirs_json=$(echo "$dirs" | jq -R -s -c 'split("\n")[:-1]')
echo "Found directories: $dirs_json"
echo "::set-output name=dirs::$dirs_json"
env:
PATH: /usr/bin:/bin
validate:
name: Validate Terraform Projects
needs: find-directories
runs-on: ubuntu-latest
strategy:
matrix:
directory: ${{ fromJson(needs.find-directories.outputs.directories) }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Validate Terraform in directory
working-directory: ${{ matrix.directory }}
run: |
echo "Validating Terraform configuration in '${{ matrix.directory }}'"
terraform init -backend=false
terraform validate