1- name : CI
1+ name : CI / IaC
22
33on :
44 pull_request :
55 branches : [dev, stg, prd]
66 types : [opened, reopened, synchronize, edited]
7- paths-ignore :
8- - ' README.md '
9- - ' LICENSE '
10- - ' .gitignore '
7+ paths :
8+ - ' iac/** '
9+ - ' .github/workflows/ci-iac.yml '
10+
1111env :
1212 node_version : " 22.x"
13- tf_version : " 1.9.8" # must match value in terraform-iac/*/app/main.tf
14- FORCE_COLOR : 3
13+ tf_version : " 1.9.0" # must match value in iac/*/app/main.tf
1514
1615jobs :
1716 env :
2524 matrix='{
2625 "env":[
2726 {
28- "tf_working_dir ":"./terraform-iac/ dev/app ",
27+ "environment_name ":"dev",
2928 "aws_account":"977306314792",
3029 "aws_gha_role":"hw-lambda-api-dev-gha"
3130 }
3938 matrix='{
4039 "env":[
4140 {
42- "tf_working_dir ":"./terraform-iac/ stg/app ",
41+ "environment_name ":"stg",
4342 "aws_account":"977306314792",
4443 "aws_gha_role":"hw-lambda-api-stg-gha"
4544 }
@@ -53,14 +52,14 @@ jobs:
5352 matrix='{
5453 "env":[
5554 {
56- "tf_working_dir ":"./terraform-iac/ prd/app ",
55+ "environment_name ":"prd",
5756 "aws_account":"539738229445",
58- "aws_gha_role":"hw-lambda-api-prd -gha"
57+ "aws_gha_role":"hw-lambda-api-cpy -gha"
5958 },
6059 {
61- "tf_working_dir ":"./terraform-iac/ cpy/app ",
60+ "environment_name ":"cpy",
6261 "aws_account":"539738229445",
63- "aws_gha_role":"hw-lambda-api-cpy -gha"
62+ "aws_gha_role":"hw-lambda-api-prd -gha"
6463 }
6564 ]
6665 }'
@@ -69,96 +68,24 @@ jobs:
6968 outputs :
7069 matrix : ${{ env.matrix }}
7170
72- test :
73- name : Test
74- runs-on : ubuntu-latest
75- timeout-minutes : 3
76- steps :
77- - uses : actions/checkout@v4
78-
79- - name : Set up Node.js
80- uses : actions/setup-node@v4
81- with :
82- node-version : ${{ env.node_version }}
83- cache : npm
84- cache-dependency-path : ' **/package-lock.json'
85-
86- - name : npm ci
87- working-directory : src
88- run : npm ci --prefer-offline
89-
90- - name : npm test
91- working-directory : src
92- run : npm test
93-
94- - name : Report test coverage to Codecov
95- uses : codecov/codecov-action@v5
96- if : env.CODECOV_TOKEN
97- env :
98- CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
99-
100- audit :
101- name : Audit
102- runs-on : ubuntu-latest
103- timeout-minutes : 3
104- steps :
105- - uses : actions/checkout@v4
106-
107- - name : Set up Node.js
108- uses : actions/setup-node@v4
109- with :
110- node-version : ${{ env.node_version }}
111-
112- # We don't need to install deps to audit them
113-
114- - name : npm audit
115- working-directory : src
116- run : npm audit --audit-level=critical
117-
118- lint :
119- name : Lint
120- runs-on : ubuntu-latest
121- timeout-minutes : 3
122- steps :
123- - uses : actions/checkout@v4
124-
125- - name : Set up Node.js
126- uses : actions/setup-node@v4
127- with :
128- node-version : ${{ env.node_version }}
129- cache : npm
130- cache-dependency-path : ' **/package-lock.json'
131-
132- - name : npm ci
133- working-directory : src
134- run : npm ci --prefer-offline
135-
136- - name : npm lint
137- working-directory : src
138- run : npm run lint
139-
14071 format :
141- name : Terraform Format
72+ name : Tofu Format
14273 timeout-minutes : 3
14374 runs-on : ubuntu-latest
144- needs : env
145- strategy :
146- matrix : ${{ fromJson(needs.env.outputs.matrix) }}
147- fail-fast : false
14875 steps :
14976 - uses : actions/checkout@v4
15077
151- - name : Terraform Setup
152- uses : hashicorp /setup-terraform@v3
78+ - name : Tofu Setup
79+ uses : opentofu /setup-opentofu@v1
15380 with :
154- terraform_version : ${{ env.tf_version }}
81+ tofu_version : ${{ env.tf_version }}
15582
156- - name : Terraform Format
157- working-directory : " ./ "
158- run : terraform fmt -check -recursive
83+ - name : Tofu Format
84+ working-directory : iac
85+ run : tofu fmt -check -recursive
15986
16087 plan :
161- name : Terraform Plan
88+ name : Tofu Plan / ${{ matrix.env.environment_name }}
16289 timeout-minutes : 6
16390 runs-on : ubuntu-latest
16491 needs : env
@@ -193,31 +120,30 @@ jobs:
193120 npm ci --production --prefer-offline
194121 zip -r lambda.zip *
195122
196- - name : Terraform Setup
197- uses : hashicorp /setup-terraform@v3
123+ - name : Tofu Setup
124+ uses : opentofu /setup-opentofu@v1
198125 with :
199- terraform_version : ${{ env.tf_version }}
126+ tofu_version : ${{ env.tf_version }}
200127
201- - name : Terraform Init
202- working-directory : ${{ matrix.env.tf_working_dir }}
203- run : terraform init
128+ - name : Tofu Init
129+ working-directory : iac/app
130+ run : tofu init -var-file=${{ matrix.env.environment_name }}.tfvars
204131
205- - name : Terraform Plan
206- working-directory : ${{ matrix.env.tf_working_dir }}
207- run : terraform plan -input=false -out plan -lock=false
132+ - name : Tofu Plan
133+ working-directory : iac/app
134+ run : tofu plan -var-file=${{ matrix.env.environment_name }}.tfvars -input=false -out plan -lock=false
208135
209- - name : Comment Terraform Plan
136+ - name : Comment Tofu Plan
210137 uses : byu-oit/github-action-tf-plan-comment@v1
211138 with :
212139 github-token : ${{ secrets.GITHUB_TOKEN }}
213- working-directory : ${{ matrix.env.tf_working_dir }}
140+ working-directory : iac/app
214141 terraform-plan-file : plan
215142
216- - name : Analyze Terraform Plan
143+ - name : Analyze Tofu Plan
217144 uses : byu-oit/github-action-tf-plan-analyzer@v2
218145 with :
219- working-directory : ${{ matrix.env.tf_working_dir }}
146+ working-directory : iac/app
220147 terraform-plan-file : plan
221148 divvycloud-username : ${{ secrets.DIVVYCLOUD_USERNAME }}
222149 divvycloud-password : ${{ secrets.DIVVYCLOUD_PASSWORD }}
223-
0 commit comments