Skip to content

Commit 3a71485

Browse files
Merge pull request #904 from NHSDigital/feature/made14-NRL-1375-codebuild-deploys
[NRL-1375] Use codebuild for deploy workflows
2 parents f3e6d1b + 99f791d commit 3a71485

File tree

7 files changed

+81
-330
lines changed

7 files changed

+81
-330
lines changed

.github/workflows/activate-stack.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ permissions:
2323
jobs:
2424
activate-stack:
2525
name: Activate ${{ inputs.stack_name }} for ${{ inputs.environment }}
26-
runs-on: [self-hosted, ci]
26+
runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
2727
environment: ${{ inputs.environment }}
2828

2929
steps:
@@ -32,18 +32,10 @@ jobs:
3232
with:
3333
ref: ${{ github.ref }}
3434

35-
- name: Setup asdf cache
36-
uses: actions/cache@v4
37-
with:
38-
path: ~/.asdf
39-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
40-
restore-keys: |
41-
${{ runner.os }}-asdf-
42-
43-
- name: Install asdf
44-
uses: asdf-vm/actions/[email protected]
45-
with:
46-
asdf_branch: v0.13.1
35+
- name: Setup environment
36+
run: |
37+
echo "${HOME}/.asdf/bin" >> $GITHUB_PATH
38+
poetry install --no-root
4739
4840
- name: Configure Management Credentials
4941
uses: aws-actions/configure-aws-credentials@v4
@@ -52,14 +44,6 @@ jobs:
5244
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
5345
role-session-name: github-actions-ci-${{ inputs.environment }}-${{ github.run_id}}
5446

55-
- name: Install zip
56-
run: sudo apt-get install zip
57-
58-
- name: Setup Python environment
59-
run: |
60-
poetry install --no-root
61-
source $(poetry env info --path)/bin/activate
62-
6347
- name: Get current environment config
6448
run: |
6549
poetry run python ./scripts/get_env_config.py all ${{ inputs.environment }}

.github/workflows/daily-build.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ jobs:
3939
run: make test
4040

4141
- name: Build Project
42-
run: |
43-
echo "PATH: ${PATH}"
44-
echo "HOME: ${HOME}"
45-
echo "python: $(which python)"
46-
echo "asdf: $(which asdf)"
47-
echo "/usr/local/bin: $(ls -la /usr/local/bin)"
48-
make build
42+
run: make build
4943

5044
- name: Configure Management Credentials
5145
uses: aws-actions/configure-aws-credentials@v4

.github/workflows/persistent-environment.yml

Lines changed: 28 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,18 @@ permissions:
2222
jobs:
2323
build:
2424
name: Build - ${{ inputs.branch_name }}
25-
runs-on: [self-hosted, ci]
25+
runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
2626

2727
steps:
2828
- name: Git clone - ${{ inputs.branch_name }}
2929
uses: actions/checkout@v4
3030
with:
3131
ref: ${{ inputs.branch_name }}
3232

33-
- name: Setup asdf cache
34-
uses: actions/cache@v4
35-
with:
36-
path: ~/.asdf
37-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
38-
restore-keys: |
39-
${{ runner.os }}-asdf-
40-
41-
- name: Install asdf
42-
uses: asdf-vm/actions/[email protected]
43-
with:
44-
asdf_branch: v0.13.1
45-
46-
- name: Install zip
47-
run: sudo apt-get install zip
48-
49-
- name: Setup Python environment
33+
- name: Setup environment
5034
run: |
35+
echo "${HOME}/.asdf/bin" >> $GITHUB_PATH
5136
poetry install --no-root
52-
source $(poetry env info --path)/bin/activate
5337
5438
- name: Run Linting
5539
run: make lint
@@ -91,26 +75,18 @@ jobs:
9175
name: Terraform Plan - ${{ inputs.environment }}
9276
needs: [build]
9377
environment: ${{ inputs.environment }}
94-
runs-on: [self-hosted, ci]
78+
runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
9579

9680
steps:
9781
- name: Git clone - ${{ inputs.branch_name }}
9882
uses: actions/checkout@v4
9983
with:
10084
ref: ${{ inputs.branch_name }}
10185

102-
- name: Setup asdf cache
103-
uses: actions/cache@v4
104-
with:
105-
path: ~/.asdf
106-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
107-
restore-keys: |
108-
${{ runner.os }}-asdf-
109-
110-
- name: Install asdf
111-
uses: asdf-vm/actions/[email protected]
112-
with:
113-
asdf_branch: v0.13.1
86+
- name: Setup environment
87+
run: |
88+
echo "${HOME}/.asdf/bin" >> $GITHUB_PATH
89+
poetry install --no-root
11490
11591
- name: Configure Management Credentials
11692
uses: aws-actions/configure-aws-credentials@v4
@@ -130,14 +106,6 @@ jobs:
130106
name: build-artifacts
131107
path: dist
132108

133-
- name: Install zip
134-
run: sudo apt-get install zip
135-
136-
- name: Setup Python environment
137-
run: |
138-
poetry install --no-root
139-
source $(poetry env info --path)/bin/activate
140-
141109
- name: Restore NRLF permissions cache
142110
uses: actions/cache/restore@v4
143111
with:
@@ -170,7 +138,7 @@ jobs:
170138
terraform-apply:
171139
name: Terraform Apply - ${{ inputs.environment }}
172140
needs: [terraform-plan]
173-
runs-on: [self-hosted, ci]
141+
runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
174142
environment: ${{ inputs.environment }}
175143

176144
steps:
@@ -179,18 +147,10 @@ jobs:
179147
with:
180148
ref: ${{ inputs.branch_name }}
181149

182-
- name: Setup asdf cache
183-
uses: actions/cache@v4
184-
with:
185-
path: ~/.asdf
186-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
187-
restore-keys: |
188-
${{ runner.os }}-asdf-
189-
190-
- name: Install asdf
191-
uses: asdf-vm/actions/[email protected]
192-
with:
193-
asdf_branch: v0.13.1
150+
- name: Setup environment
151+
run: |
152+
echo "${HOME}/.asdf/bin" >> $GITHUB_PATH
153+
poetry install --no-root
194154
195155
- name: Download build artifacts
196156
uses: actions/download-artifact@v4
@@ -220,14 +180,6 @@ jobs:
220180
account=$(echo '${{ inputs.environment }}' | cut -d '-' -f1)
221181
make truststore-pull-server ENV=${account}
222182
223-
- name: Install zip
224-
run: sudo apt-get install zip
225-
226-
- name: Setup Python environment
227-
run: |
228-
poetry install --no-root
229-
source $(poetry env info --path)/bin/activate
230-
231183
- name: Terraform Init
232184
run: |
233185
inactive_stack=$(poetry run python ./scripts/get_env_config.py inactive-stack ${{ inputs.environment }})
@@ -252,7 +204,7 @@ jobs:
252204
activate-stack:
253205
name: Activate - ${{ inputs.environment }}
254206
needs: [terraform-apply]
255-
runs-on: [self-hosted, ci]
207+
runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
256208
environment: ${{ inputs.environment }}
257209

258210
steps:
@@ -261,18 +213,10 @@ jobs:
261213
with:
262214
ref: ${{ inputs.branch_name }}
263215

264-
- name: Setup asdf cache
265-
uses: actions/cache@v4
266-
with:
267-
path: ~/.asdf
268-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
269-
restore-keys: |
270-
${{ runner.os }}-asdf-
271-
272-
- name: Install asdf
273-
uses: asdf-vm/actions/[email protected]
274-
with:
275-
asdf_branch: v0.13.1
216+
- name: Setup environment
217+
run: |
218+
echo "${HOME}/.asdf/bin" >> $GITHUB_PATH
219+
poetry install --no-root
276220
277221
- name: Configure Management Credentials
278222
uses: aws-actions/configure-aws-credentials@v4
@@ -281,14 +225,6 @@ jobs:
281225
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
282226
role-session-name: github-actions-ci-${{ inputs.environment }}-${{ github.run_id}}
283227

284-
- name: Install zip
285-
run: sudo apt-get install zip
286-
287-
- name: Setup Python environment
288-
run: |
289-
poetry install --no-root
290-
source $(poetry env info --path)/bin/activate
291-
292228
- name: Activate Stack
293229
run: |
294230
inactive_stack=$(poetry run python ./scripts/get_env_config.py inactive-stack ${{ inputs.environment }})
@@ -297,7 +233,7 @@ jobs:
297233
post-release-verify:
298234
name: Verify - ${{ inputs.environment }}
299235
needs: [activate-stack]
300-
runs-on: [self-hosted, ci]
236+
runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
301237
environment: ${{ inputs.environment }}
302238

303239
steps:
@@ -306,18 +242,10 @@ jobs:
306242
with:
307243
ref: ${{ inputs.branch_name }}
308244

309-
- name: Setup asdf cache
310-
uses: actions/cache@v4
311-
with:
312-
path: ~/.asdf
313-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
314-
restore-keys: |
315-
${{ runner.os }}-asdf-
316-
317-
- name: Install asdf
318-
uses: asdf-vm/actions/[email protected]
319-
with:
320-
asdf_branch: v0.13.1
245+
- name: Setup environment
246+
run: |
247+
echo "${HOME}/.asdf/bin" >> $GITHUB_PATH
248+
poetry install --no-root
321249
322250
- name: Configure Management Credentials
323251
uses: aws-actions/configure-aws-credentials@v4
@@ -326,14 +254,6 @@ jobs:
326254
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
327255
role-session-name: github-actions-ci-${{ inputs.environment }}-${{ github.run_id}}
328256

329-
- name: Install zip
330-
run: sudo apt-get install zip
331-
332-
- name: Setup Python environment
333-
run: |
334-
poetry install --no-root
335-
source $(poetry env info --path)/bin/activate
336-
337257
- name: "Smoke Test"
338258
run: |
339259
make ENV=${{ inputs.environment }} test-smoke-public
@@ -342,7 +262,7 @@ jobs:
342262
name: Rollback - ${{ inputs.environment }}
343263
needs: [post-release-verify]
344264
if: always() && ( needs.post-release-verify.result == 'failure' )
345-
runs-on: [self-hosted, ci]
265+
runs-on: codebuild-nhsd-nrlf-ci-build-project-${{ github.run_id }}-${{ github.run_attempt }}
346266
environment: ${{ inputs.environment }}
347267

348268
steps:
@@ -351,18 +271,10 @@ jobs:
351271
with:
352272
ref: ${{ inputs.branch_name }}
353273

354-
- name: Setup asdf cache
355-
uses: actions/cache@v4
356-
with:
357-
path: ~/.asdf
358-
key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
359-
restore-keys: |
360-
${{ runner.os }}-asdf-
361-
362-
- name: Install asdf
363-
uses: asdf-vm/actions/[email protected]
364-
with:
365-
asdf_branch: v0.13.1
274+
- name: Setup environment
275+
run: |
276+
echo "${HOME}/.asdf/bin" >> $GITHUB_PATH
277+
poetry install --no-root
366278
367279
- name: Configure Management Credentials
368280
uses: aws-actions/configure-aws-credentials@v4
@@ -371,14 +283,6 @@ jobs:
371283
role-to-assume: ${{ secrets.MGMT_ROLE_ARN }}
372284
role-session-name: github-actions-ci-${{ inputs.environment }}-${{ github.run_id}}
373285

374-
- name: Install zip
375-
run: sudo apt-get install zip
376-
377-
- name: Setup Python environment
378-
run: |
379-
poetry install --no-root
380-
source $(poetry env info --path)/bin/activate
381-
382286
- name: Deactivate Stack
383287
run: |
384288
inactive_stack_name=$(poetry run python ./scripts/get_env_config.py inactive-stack ${{ inputs.environment }})

0 commit comments

Comments
 (0)