generated from hackforla/.github-hackforla-base-repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 14
89 lines (83 loc) · 3.11 KB
/
terraform-plan.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: PR Terraform Plan
on: [pull_request]
permissions:
contents: read
pull-requests: write
jobs:
changed-files:
name: Get changed terraform directories
runs-on: ubuntu-latest
outputs:
module-change: ${{ steps.changed-files.outputs.module-change }}
project-change: ${{ steps.changed-files.outputs.project-change }}
environment-change: ${{ steps.changed-files.outputs.environment-change }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: dorny/paths-filter@v2
with:
filters: |
module-change:
- 'terraform-modules/**'
project-change:
- 'terraform-incubator/*/project/*.tf'
environment-change:
- 'terraform-incubator/*/!(project)/*.tf'
list-files: json
- name: List all changed files
run: echo '${{ steps.changed-files.outputs.module-change_files }}'; echo '${{ steps.changed-files.outputs.project-change_files }}'; echo '${{ steps.changed-files.outputs.environment-change_files }}'
plan-all:
runs-on: ubuntu-latest
name: Terraform plan - all directories
needs: [changed-files]
if: ${{ needs.changed-files.outputs.module-change == 'true' }}
strategy:
matrix:
directory: ${{ needs.changed-files.outputs.environment-change }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{secrets.INCUBATOR_AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: terraform plan
uses: dflook/terraform-plan@v1
with:
path: ${{ matrix.directory }}
plan-project:
runs-on: ubuntu-latest
name: Terraform plan - Project changes
needs: [changed-files]
if: ${{ needs.changed-files.outputs.project-change == 'true' && needs.changed-files.outputs.module-change == 'false'}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{secrets.INCUBATOR_AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: terraform plan
uses: dflook/terraform-plan@v1
with:
path: terraform-incubator/people-depot/dev
plan-environment:
runs-on: ubuntu-latest
name: Terraform plan - Env changes
needs: [changed-files]
if: ${{ needs.changed-files.outputs.environment-change == 'true' && needs.changed-files.outputs.module-change == 'false' && needs.changed-files.outputs.project-change == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{secrets.INCUBATOR_AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.INCUBATOR_AWS_SECRET_ACCESS_KEY}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: terraform plan
uses: dflook/terraform-plan@v1
with:
path: terraform-incubator/people-depot/dev