149 lines (132 loc) · 5.49 KB
/
wc-test.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
name: test
on:
workflow_call:
secrets:
gh_token:
required: false
gh_app_id:
required: false
gh_app_private_key:
required: false
terraform_private_module_ssh_key: # This isn't needed if you don't use SSH key to checkout private Terraform Modules
required: false
secrets:
required: false
env:
TFACTION_IS_APPLY: 'false'
permissions:
id-token: write
contents: read
pull-requests: write
jobs:
setup:
runs-on: ubuntu-latest
outputs:
targets: ${{ steps.list-targets.outputs.targets }}
modules: ${{ steps.list-targets.outputs.modules }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: suzuki-shunsuke/github-token-action@04d633c696e9d09e958c8b815c75db9606d6d927 # v0.2.0
id: token
with:
github_token: ${{secrets.gh_token}}
github_app_id: ${{secrets.gh_app_id}}
github_app_private_key: ${{secrets.gh_app_private_key}}
default_github_token: ${{github.token}}
- uses: aquaproj/aqua-installer@d9c4b5d107a17831a8c8718efa4ce67a0923d1f5 # v2.1.3
with:
aqua_version: v2.16.4
env:
AQUA_GITHUB_TOKEN: ${{steps.token.outputs.token}}
- uses: suzuki-shunsuke/tfaction/list-targets@5731fade20e41c1905c04095f0e3d68fac14a636 # v0.7.3
id: list-targets
test-module:
name: "test-module (${{matrix.target}})"
runs-on: ubuntu-latest
needs: setup
# if services is empty, the build job is skipped
if: "join(fromJSON(needs.setup.outputs.modules), '') != ''"
env:
TFACTION_TARGET: ${{matrix.target}}
strategy:
matrix:
target: ${{fromJSON(needs.setup.outputs.modules)}}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: suzuki-shunsuke/github-token-action@04d633c696e9d09e958c8b815c75db9606d6d927 # v0.2.0
id: token
with:
github_token: ${{secrets.gh_token}}
github_app_id: ${{secrets.gh_app_id}}
github_app_private_key: ${{secrets.gh_app_private_key}}
default_github_token: ${{github.token}}
- uses: aquaproj/aqua-installer@d9c4b5d107a17831a8c8718efa4ce67a0923d1f5 # v2.1.3
with:
aqua_version: v2.16.4
aqua_opts: -l -a
working_directory: ${{matrix.target}}
env:
AQUA_GITHUB_TOKEN: ${{steps.token.outputs.token}}
- uses: suzuki-shunsuke/tfaction/test-module@26effa08b92b77b5cfe04e2a25c15845fd00b04f # v0.7.2
with:
github_app_token: ${{steps.token.outputs.token}}
plan:
name: "plan (${{matrix.target.target}})"
runs-on: ${{matrix.target.runs_on}}
needs: setup
# if services is empty, the build job is skipped
if: "join(fromJSON(needs.setup.outputs.targets), '') != ''"
strategy:
fail-fast: true
matrix:
target: ${{fromJSON(needs.setup.outputs.targets)}}
env:
TFACTION_TARGET: ${{matrix.target.target}}
TFACTION_JOB_TYPE: ${{matrix.target.job_type}}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: suzuki-shunsuke/github-token-action@04d633c696e9d09e958c8b815c75db9606d6d927 # v0.2.0
id: token
with:
github_token: ${{secrets.gh_token}}
github_app_id: ${{secrets.gh_app_id}}
github_app_private_key: ${{secrets.gh_app_private_key}}
default_github_token: ${{github.token}}
- uses: aquaproj/aqua-installer@d9c4b5d107a17831a8c8718efa4ce67a0923d1f5 # v2.1.3
with:
aqua_version: v2.16.4
env:
AQUA_GITHUB_TOKEN: ${{steps.token.outputs.token}}
- uses: suzuki-shunsuke/tfaction/export-secrets@26effa08b92b77b5cfe04e2a25c15845fd00b04f # v0.7.2
with:
secrets: ${{secrets.secrets}}
# This is required to download private modules in `terraform init`
- run: gh auth setup-git
env:
GITHUB_TOKEN: ${{steps.token.outputs.token}}
- uses: suzuki-shunsuke/tfaction/setup@26effa08b92b77b5cfe04e2a25c15845fd00b04f # v0.7.2
with:
github_app_token: ${{steps.token.outputs.token}}
ssh_key: ${{secrets.terraform_private_module_ssh_key}} # This isn't needed if you don't use SSH key to checkout private Terraform Modules
- uses: suzuki-shunsuke/tfaction/get-target-config@26effa08b92b77b5cfe04e2a25c15845fd00b04f # v0.7.2
id: target-config
- run: |
set -euo pipefail
github-comment exec -var "tfaction_target:$TFACTION_TARGET" -- tfprovidercheck -v
github-comment exec -var "tfaction_target:$TFACTION_TARGET" -- terraform version -json | github-comment exec -- tfprovidercheck
working-directory: ${{ steps.target-config.outputs.working_directory }}
env:
TFPROVIDERCHECK_CONFIG_BODY: |
providers:
- name: registry.terraform.io/hashicorp/google
- name: registry.terraform.io/hashicorp/aws
- name: registry.terraform.io/hashicorp/null
- name: registry.terraform.io/integrations/github
GITHUB_TOKEN: ${{steps.token.outputs.token}} # For github-comment
- uses: suzuki-shunsuke/tfaction/test@26effa08b92b77b5cfe04e2a25c15845fd00b04f # v0.7.2
with:
github_app_token: ${{steps.token.outputs.token}}
- uses: suzuki-shunsuke/tfaction/plan@5731fade20e41c1905c04095f0e3d68fac14a636 # v0.7.3
with:
github_app_token: ${{steps.token.outputs.token}}