-
Notifications
You must be signed in to change notification settings - Fork 13
70 lines (61 loc) · 1.84 KB
/
terraform.yml
File metadata and controls
70 lines (61 loc) · 1.84 KB
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
name: 'Validate Terraform'
on:
push:
branches:
- main
pull_request:
permissions:
pull-requests: write
jobs:
terraform:
name: 'Validate Terraform'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.1 # Required as of Apr 15 2021 because of breaking changes in tf 0.15
- name: Terraform fmt
id: fmt
run: terraform fmt -recursive
continue-on-error: true
- name: Terraform Init
id: init
run: |
EXIT=0
for dir in modules/* ; do
echo "::group::Module $dir"
pushd $dir ; terraform init -backend=false ; E=$?; echo "Exit code: $E";popd
echo "::endgroup::"
EXIT=$((E+EXIT))
done
exit $EXIT
- name: Terraform Validate
id: validate
env:
# Not used, but necessary as some sub-modules reference it.
AWS_REGION: 'us-east-1'
run: |
EXIT=0
for dir in modules/* ; do
echo "::group::Module $dir"
pushd $dir; terraform validate -no-color; E=$?; echo "Exit code: $E"; popd
echo "::endgroup::"
EXIT=$((E+EXIT))
done
exit $EXIT
- uses: actions/github-script@0.9.0
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Validation 🤖${{ steps.validate.outputs.stdout }}
`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})