1- name : ' Terraform GitHub Actions'
1+ name : static-checks
2+
23on :
34 pull_request :
4- branches :
5- - master
5+
66jobs :
7- fmt :
8- name : ' terraform fmt '
7+ versionExtract :
8+ name : Get min/max versions
99 runs-on : ubuntu-latest
10- steps :
11- - name : ' Checkout'
12- uses : actions/checkout@v2.3.4
13-
14- - name : ' Terraform Format'
15- uses : ' clouddrove/github-actions@v7.0'
16- with :
17- actions_subcommand : ' fmt'
1810
19- DNS :
20- name : ' DNS'
21- needs : fmt
22- runs-on : ubuntu-latest
2311 steps :
24- - name : ' Checkout'
25- uses : actions/checkout@v2.3.4
12+ - name : Checkout
13+ uses : actions/checkout@v2
2614
27- - name : ' Configure AWS Credentials '
28- uses : clouddrove/configure-aws-credentials@v1
29- with :
30- aws-access-key-id : ${{ secrets.TEST_AWS_ACCESS_KEY }}
31- aws-secret-access-key : ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
32- aws-region : us-east-2
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 }}
3321
34- - name : ' Terraform init for generate certificate dns'
35- uses : ' clouddrove/github-actions@v7.0'
36- with :
37- actions_subcommand : ' init'
38- tf_actions_working_dir : ./_example/generate-certificate-dns
39-
40- - name : ' Terraform validate for generate certificate dns'
41- uses : ' clouddrove/github-actions@v7.0'
42- with :
43- actions_subcommand : ' validate'
44- tf_actions_working_dir : ./_example/generate-certificate-dns
4522
46- - name : ' Terraform plan for generate certificate dns'
47- uses : ' clouddrove/github-actions@v7.0'
48- with :
49- actions_subcommand : ' plan'
50- tf_actions_working_dir : ./_example/generate-certificate-dns
51- Email :
52- name : ' Email'
53- needs : fmt
23+ versionEvaluate :
24+ name : Evaluate Terraform versions
5425 runs-on : ubuntu-latest
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/
35+
5536 steps :
37+ - name : Checkout
38+ uses : actions/checkout@v2
5639
57- - name : ' Checkout'
58- uses : actions/checkout@v2.3.4
40+ - name : Install Terraform v${{ matrix.version }}
41+ uses : hashicorp/setup-terraform@v1
42+ with :
43+ terraform_version : ${{ matrix.version }}
5944
6045 - name : ' Configure AWS Credentials'
6146 uses : clouddrove/configure-aws-credentials@v1
@@ -64,55 +49,34 @@ jobs:
6449 aws-secret-access-key : ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
6550 aws-region : us-east-2
6651
67- - name : ' Terraform init for generate certificate email'
68- uses : ' clouddrove/github-actions@v7.0'
69- with :
70- actions_subcommand : ' init'
71- tf_actions_working_dir : ./_example/generate-certificate-email
72-
73- - name : ' Terraform validate for generate certificate email'
74- uses : ' clouddrove/github-actions@v7.0'
75- with :
76- actions_subcommand : ' validate'
77- tf_actions_working_dir : ./_example/generate-certificate-email
52+ - name : Init & validate v${{ matrix.version }}
53+ run : |
54+ cd ${{ matrix.directory }}
55+ terraform init
56+ terraform validate
7857
79- - name : ' Terraform plan for generate certificate email '
80- uses : ' clouddrove/github-actions@v7.0 '
58+ - name : tflint
59+ uses : reviewdog/action-tflint@master
8160 with :
82- actions_subcommand : ' plan'
83- tf_actions_working_dir : ./_example/generate-certificate-email
84-
85- pre-commit :
86- name : ' Pre-Commit'
87- needs :
88- - fmt
89- - DNS
90- - Email
61+ github_token : ${{ secrets.GITHUB }}
62+ working_directory : ${{ matrix.directory }}
63+ fail_on_error : ' true'
64+ filter_mode : ' nofilter'
65+ flags : ' --module'
66+
67+ format :
68+ name : Check code format
9169 runs-on : ubuntu-latest
92- steps :
93- - name : ' Checkout'
94- uses : actions/checkout@v2.3.4
95-
96- - name : ' Install Tflint'
97- run : |
98- curl https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
99-
100- - name : ' Pre-Commit 🔎'
101- uses : pre-commit/action@v2.0.3
102- continue-on-error : true
70+ needs : versionExtract
10371
72+ steps :
73+ - name : Checkout
74+ uses : actions/checkout@v2
10475
105- - name : ' Pre-Commit 🔎'
106- uses : pre-commit/action@v2.0.3
107- continue-on-error : true
108-
109- - name : ' Slack Notification'
110- uses : clouddrove/action-slack@v2
76+ - name : Install Terraform v${{ needs.versionExtract.outputs.maxVersion }}
77+ uses : hashicorp/setup-terraform@v1
11178 with :
112- status : ${{ job.status }}
113- fields : repo,author
114- author_name : ' CloudDrove'
115- env :
116- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # required
117- SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
118- if : always()
79+ terraform_version : ${{ needs.versionExtract.outputs.maxVersion }}
80+
81+ - name : Check Terraform format changes
82+ run : terraform fmt --recursive
0 commit comments