-
Notifications
You must be signed in to change notification settings - Fork 16
54 lines (45 loc) · 1.28 KB
/
terraform-validation.yml
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
name: Terraform Validation
on:
pull_request:
paths:
- 'iac/*'
jobs:
targets:
runs-on: ubuntu-latest
outputs:
paths: ${{ steps.ls.outputs.paths }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Discover Terraform targets
id: ls
run: echo "paths=$(ls -d iac/*/*/* | jq --raw-input --slurp --compact-output 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT}
validate:
runs-on: ubuntu-latest
needs: targets
strategy:
fail-fast: false
matrix:
path: ${{ fromJson(needs.targets.outputs.paths) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform Formatting
uses: dflook/terraform-fmt-check@v1
with:
path: ${{ matrix.path }}
- name: Terraform Validation
uses: dflook/terraform-validate@v1
with:
path: ${{ matrix.path }}
- uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- uses: google-github-actions/setup-gcloud@v2
- name: Terraform Plan
uses: dflook/terraform-plan@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
add_github_comment: false
path: ${{ matrix.path }}