1
- name : ' Terraform GitHub Actions'
1
+ name : static-checks
2
+
2
3
on :
3
4
pull_request :
4
- branches :
5
- - master
6
5
7
6
jobs :
8
- fmt :
9
- name : ' terraform fmt '
7
+ versionExtract :
8
+ name : Get min/max versions
10
9
runs-on : ubuntu-latest
11
- steps :
12
- - name : ' Checkout'
13
- uses : actions/checkout@master
14
-
15
- - name : ' Terraform Format'
16
- uses : ' clouddrove/github-actions@v8.0'
17
- with :
18
- actions_subcommand : ' fmt'
19
10
20
- multi_node_non_vpc :
21
- name : ' multi_node_non_vpc'
22
- needs : fmt
23
- runs-on : ubuntu-latest
24
11
steps :
12
+ - name : Checkout
13
+ uses : actions/checkout@v2
25
14
26
- - name : ' Checkout'
27
- uses : actions/checkout@master
28
-
29
- - name : ' Configure AWS Credentials'
30
- uses : clouddrove/configure-aws-credentials@v1
31
- with :
32
- aws-access-key-id : ${{ secrets.TEST_AWS_ACCESS_KEY }}
33
- aws-secret-access-key : ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
34
- aws-region : us-east-2
35
-
36
- - name : ' Terraform init multi_node_non_vpc'
37
- uses : ' clouddrove/github-actions@v8.0'
38
- with :
39
- actions_subcommand : ' init'
40
- tf_actions_working_dir : ./_example/multi_node_non_vpc
41
-
42
- - name : ' Terraform validate multi_node_non_vpc'
43
- uses : ' clouddrove/github-actions@v8.0'
44
- with :
45
- actions_subcommand : ' validate'
46
- tf_actions_working_dir : ./_example/multi_node_non_vpc
15
+ - name : Terraform min/max versions
16
+ id : minMax
17
+ uses : clowdhaus/terraform-min-max@main
18
+ outputs :
19
+ minVersion : ${{ steps.minMax.outputs.minVersion }}
20
+ maxVersion : ${{ steps.minMax.outputs.maxVersion }}
47
21
48
- - name : ' Terraform plan multi_node_non_vpc'
49
- uses : ' clouddrove/github-actions@v8.0'
50
- with :
51
- actions_subcommand : ' plan'
52
- tf_actions_working_dir : ./_example/multi_node_non_vpc
53
22
54
- multi_node_vpc :
55
- name : ' multi_node_vpc'
56
- needs : fmt
23
+ versionEvaluate :
24
+ name : Evaluate Terraform versions
57
25
runs-on : ubuntu-latest
58
- steps :
59
- - name : ' Checkout'
60
- uses : actions/checkout@master
26
+ needs : versionExtract
27
+ strategy :
28
+ fail-fast : false
29
+ matrix :
30
+ version :
31
+ - ${{ needs.versionExtract.outputs.minVersion }}
32
+ - ${{ needs.versionExtract.outputs.maxVersion }}
33
+ directory :
34
+ - _example/multi_node_non_vpc
35
+ - _example/multi_node_vpc
36
+ - _example/single_node_non_vpc
37
+ - _example/single_node_vpc
61
38
62
- - name : ' Configure AWS Credentials'
63
- uses : clouddrove/configure-aws-credentials@v1
64
- with :
65
- aws-access-key-id : ${{ secrets.TEST_AWS_ACCESS_KEY }}
66
- aws-secret-access-key : ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
67
- aws-region : us-east-2
68
-
69
- - name : ' Terraform init multi_node_vpc'
70
- uses : ' clouddrove/github-actions@v8.0'
71
- with :
72
- actions_subcommand : ' init'
73
- tf_actions_working_dir : ./_example/multi_node_vpc
74
-
75
- - name : ' Terraform validate multi_node_vpc'
76
- uses : ' clouddrove/github-actions@v8.0'
77
- with :
78
- actions_subcommand : ' validate'
79
- tf_actions_working_dir : ./_example/multi_node_vpc
80
-
81
- - name : ' Terraform plan multi_node_vpc'
82
- uses : ' clouddrove/github-actions@v8.0'
83
- with :
84
- actions_subcommand : ' plan'
85
- tf_actions_working_dir : ./_example/multi_node_vpc
86
-
87
- single_node_non_vpc :
88
- name : ' single_node_non_vpc'
89
- needs : fmt
90
- runs-on : ubuntu-latest
91
39
steps :
92
- - name : ' Checkout'
93
- uses : actions/checkout@master
40
+ - name : Checkout
41
+ uses : actions/checkout@v2
94
42
95
- - name : ' Configure AWS Credentials '
96
- uses : clouddrove/configure-aws-credentials @v1
43
+ - name : Install Terraform v${{ matrix.version }}
44
+ uses : hashicorp/setup-terraform @v1
97
45
with :
98
- aws-access-key-id : ${{ secrets.TEST_AWS_ACCESS_KEY }}
99
- aws-secret-access-key : ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
100
- aws-region : us-east-2
101
-
102
- - name : ' Terraform init for single_node_non_vpc'
103
- uses : ' clouddrove/github-actions@v8.0'
104
- with :
105
- actions_subcommand : ' init'
106
- tf_actions_working_dir : ./_example/single_node_non_vpc
107
-
108
- - name : ' Terraform validate for single_node_non_vpc'
109
- uses : ' clouddrove/github-actions@v8.0'
110
- with :
111
- actions_subcommand : ' validate'
112
- tf_actions_working_dir : ./_example/single_node_non_vpc
113
-
114
- - name : ' Terraform plan for single_node_non_vpc'
115
- uses : ' clouddrove/github-actions@v8.0'
116
- with :
117
- actions_subcommand : ' plan'
118
- tf_actions_working_dir : ./_example/single_node_non_vpc
119
-
120
- single_node_vpc :
121
- name : ' single_node_non_vpc'
122
- needs : fmt
123
- runs-on : ubuntu-latest
124
- steps :
125
- - name : ' Checkout'
126
- uses : actions/checkout@master
46
+ terraform_version : ${{ matrix.version }}
127
47
128
48
- name : ' Configure AWS Credentials'
129
49
uses : clouddrove/configure-aws-credentials@v1
@@ -132,53 +52,35 @@ jobs:
132
52
aws-secret-access-key : ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
133
53
aws-region : us-east-2
134
54
135
- - name : ' Terraform init for single_node_vpc'
136
- uses : ' clouddrove/github-actions@v8.0'
137
- with :
138
- actions_subcommand : ' init'
139
- tf_actions_working_dir : ./_example/single_node_vpc
140
-
141
- - name : ' Terraform validate for single_node_vpc'
142
- uses : ' clouddrove/github-actions@v8.0'
143
- with :
144
- actions_subcommand : ' validate'
145
- tf_actions_working_dir : ./_example/single_node_vpc
146
-
147
- - name : ' Terraform plan for single_node_vpc'
148
- uses : ' clouddrove/github-actions@v8.0'
149
- with :
150
- actions_subcommand : ' plan'
151
- tf_actions_working_dir : ./_example/single_node_vpc
152
-
153
-
154
- pre-commit :
155
- name : ' Pre-Commit'
156
- needs :
157
- - fmt
158
- - multi_node_non_vpc
159
- - multi_node_vpc
160
- - single_node_non_vpc
161
- - single_node_vpc
162
- runs-on : ubuntu-latest
163
- steps :
164
- - name : ' Checkout'
165
- uses : actions/checkout@v2.3.4
166
-
167
- - name : ' Install Tflint'
55
+ - name : Init & validate v${{ matrix.version }}
168
56
run : |
169
- curl https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
57
+ cd ${{ matrix.directory }}
58
+ terraform init
59
+ terraform validate
60
+
61
+
62
+ - name : tflint
63
+ uses : reviewdog/action-tflint@master
64
+ with :
65
+ github_token : ${{ secrets.GITHUB }}
66
+ working_directory : ${{ matrix.directory }}
67
+ fail_on_error : ' true'
68
+ filter_mode : ' nofilter'
69
+ flags : ' --module'
70
+
71
+ format :
72
+ name : Check code format
73
+ runs-on : ubuntu-latest
74
+ needs : versionExtract
170
75
171
- - name : ' Pre-Commit 🔎 '
172
- uses : pre-commit/action@v2.0.3
173
- continue-on-error : true
76
+ steps :
77
+ - name : Checkout
78
+ uses : actions/checkout@v2
174
79
175
- - name : ' Slack Notification '
176
- uses : clouddrove/action-slack@v2
80
+ - name : Install Terraform v${{ needs.versionExtract.outputs.maxVersion }}
81
+ uses : hashicorp/setup-terraform@v1
177
82
with :
178
- status : ${{ job.status }}
179
- fields : repo,author
180
- author_name : ' CloudDrove'
181
- env :
182
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # required
183
- SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
184
- if : always()
83
+ terraform_version : ${{ needs.versionExtract.outputs.maxVersion }}
84
+
85
+ - name : Check Terraform format changes
86
+ run : terraform fmt --recursive
0 commit comments