generated from adnoctem/boilerplate-terraform-module
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (88 loc) · 2.69 KB
/
testing.yaml
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: "Testing"
on:
workflow_dispatch:
push:
branches:
- "**"
pull_request:
branches:
- "**"
permissions:
contents: write
pull-requests: write
defaults:
run:
shell: bash
concurrency:
group: "${{ github.workflow }}@${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
jobs:
test:
name: Test
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
terraform_version: [1.7, 1.8, 1.9]
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} # https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "~${{ matrix.terraform_version }}"
- name: Set up TFLint
uses: terraform-linters/setup-tflint@v4
with:
github_token: ${{ env.GITHUB_TOKEN }}
tflint_version: "v0.53.0"
- name: Cache TFLint plugins
uses: actions/cache@v4
with:
path: ~/.tflint.d/plugins
key: ${{ matrix.os }}-tflint-${{ hashFiles('.tflint.hcl') }}
- name: Cache Terraform dependencies
uses: actions/cache@v4
with:
path: .terraform
key: ${{ matrix.os }}-terraform-${{ hashFiles('versions.tf') }}
- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Init TFLint
run: tflint --init
- name: Run TFLint
id: tflint
run: tflint -f compact
dispatch:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
needs: [test]
steps:
- name: Dispatch a release workflow run
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} # ref: https://github.com/actions/runner/issues/1251
uses: actions/github-script@v7
with:
github-token: "${{ env.GITHUB_TOKEN }}"
script: |
const payload = {
run_id: "${{ github.run_id }}",
sha: "${{ github.sha }}"
}
console.log("Sending event payload", JSON.stringify(payload, null, 2));
const { owner, repo } = context.repo;
await github.rest.repos.createDispatchEvent({
owner,
repo,
event_type: 'release',
client_payload: payload
});