-
Notifications
You must be signed in to change notification settings - Fork 16
74 lines (62 loc) · 1.67 KB
/
terraform-report.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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}
lint:
runs-on: ubuntu-latest
needs: targets
strategy:
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 }}
validate:
runs-on: ubuntu-latest
needs: targets
strategy:
matrix:
path: ${{ fromJson(needs.targets.outputs.paths) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Terraform Validation
uses: dflook/terraform-validate@v1
with:
path: ${{ matrix.path }}
plan:
runs-on: ubuntu-latest
needs: targets
strategy:
matrix:
path: ${{ fromJson(needs.targets.outputs.paths) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- run: echo ${{ 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:
path: ${{ matrix.path }}