Skip to content

Commit 7fe89e6

Browse files
authored
Merge pull request #6280 from NHSDigital/next
2 parents a7fd930 + fb636d3 commit 7fe89e6

File tree

189 files changed

+4061
-2388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+4061
-2388
lines changed

.github/pull_request_template.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
## Screenshots
2-
3-
## Pre-release tasks
1+
...
42

5-
- ...
3+
[Jira Issue - MAV-XXX](https://nhsd-jira.digital.nhs.uk/browse/MAV-XXX)
64

7-
## Post-release tasks
5+
## Screenshots
86

9-
- ...
7+
...

.github/workflows/build-and-push-image.yml

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ jobs:
2929
strategy:
3030
fail-fast: true
3131
matrix:
32-
image_type: ["webapp", "ops"]
32+
image_type: [webapp, ops]
3333
permissions:
3434
id-token: write
3535
outputs:
36-
webapp-build-needed: ${{ steps.check-dev-image.outputs.webapp-build-needed || steps.check-prod-image.outputs.webapp-build-needed }}
37-
ops-build-needed: ${{ steps.check-dev-image.outputs.ops-build-needed || steps.check-prod-image.outputs.ops-build-needed }}
36+
webapp-build-needed: >-
37+
${{ steps.check-dev-image.outputs.webapp-build-needed ||
38+
steps.check-prod-image.outputs.webapp-build-needed }}
39+
ops-build-needed: >-
40+
${{ steps.check-dev-image.outputs.ops-build-needed ||
41+
steps.check-prod-image.outputs.ops-build-needed }}
3842
steps:
3943
- name: Configure AWS Dev Credentials
4044
uses: aws-actions/configure-aws-credentials@v6
@@ -44,7 +48,8 @@ jobs:
4448
- name: Check if dev image exists
4549
id: check-dev-image
4650
run: |
47-
if aws ecr describe-images --repository-name mavis/${{ matrix.image_type }} --image-ids "imageTag=$git_ref" > /dev/null 2>&1; then
51+
if aws ecr describe-images --repository-name mavis/${{ matrix.image_type }} \
52+
--image-ids "imageTag=$git_ref" > /dev/null 2>&1; then
4853
echo "Dev image with given tag already exists"
4954
else
5055
echo "Dev image does not exist. Build needed"
@@ -60,7 +65,8 @@ jobs:
6065
if: env.PUSH_IMAGE_TO_PRODUCTION == 'true'
6166
id: check-prod-image
6267
run: |
63-
if aws ecr describe-images --repository-name mavis/${{ matrix.image_type }} --image-ids "imageTag=$git_ref" > /dev/null 2>&1; then
68+
if aws ecr describe-images --repository-name mavis/${{ matrix.image_type }} \
69+
--image-ids "imageTag=$git_ref" > /dev/null 2>&1; then
6470
echo "Production image with given tag already exists"
6571
else
6672
echo "Production image does not exist. Build needed"
@@ -75,57 +81,32 @@ jobs:
7581
steps:
7682
- name: Set aws roles
7783
id: determine-aws-roles
84+
# yamllint disable rule:line-length
7885
run: |
7986
if [ "$PUSH_IMAGE_TO_PRODUCTION" = "true" ]; then
8087
echo 'aws-roles=["arn:aws:iam::393416225559:role/GithubDeployMavisAndInfrastructure", "arn:aws:iam::820242920762:role/GithubDeployMavisAndInfrastructure"]' >> "$GITHUB_OUTPUT"
8188
else
8289
echo 'aws-roles=["arn:aws:iam::393416225559:role/GithubDeployMavisAndInfrastructure"]' >> "$GITHUB_OUTPUT"
8390
fi
84-
build:
85-
needs: check-image-presence
86-
if: needs.check-image-presence.outputs.webapp-build-needed == 'true' || needs.check-image-presence.outputs.ops-build-needed == 'true'
91+
# yamllint enable rule:line-length
92+
build-and-push:
93+
needs: [check-image-presence, define-matrix]
94+
if: >-
95+
needs.check-image-presence.outputs.webapp-build-needed == 'true' ||
96+
needs.check-image-presence.outputs.ops-build-needed == 'true'
8797
runs-on: ubuntu-latest
8898
permissions:
8999
id-token: write
100+
strategy:
101+
matrix:
102+
aws-role: ${{ fromJSON(needs.define-matrix.outputs.aws-roles) }}
90103
steps:
91104
- name: Checkout code
92105
uses: actions/checkout@v6
93106
with:
94107
ref: ${{ env.git_ref }}
95108
- name: Write build SHA
96109
run: git rev-parse HEAD > public/sha
97-
- name: Build webapp docker image
98-
run: docker build -t "mavis-webapp:latest" .
99-
- name: Save web image
100-
run: docker save -o image.tar mavis-webapp:latest
101-
- name: Upload web image
102-
uses: actions/upload-artifact@v7
103-
with:
104-
name: webapp-image
105-
path: image.tar
106-
- name: Build ops docker image
107-
run: docker build -f ops.Dockerfile -t "mavis-ops:latest" .
108-
- name: Save ops image
109-
run: docker save -o image.tar mavis-ops:latest
110-
- name: Upload ops image
111-
uses: actions/upload-artifact@v7
112-
with:
113-
name: ops-image
114-
path: image.tar
115-
push:
116-
runs-on: ubuntu-latest
117-
needs: [build, define-matrix]
118-
permissions:
119-
id-token: write
120-
strategy:
121-
matrix:
122-
aws-role: ${{ fromJSON(needs.define-matrix.outputs.aws-roles) }}
123-
image_type: ["webapp", "ops"]
124-
steps:
125-
- name: Download Docker image
126-
uses: actions/download-artifact@v8
127-
with:
128-
name: ${{ matrix.image_type }}-image
129110
- name: Configure AWS Credentials
130111
uses: aws-actions/configure-aws-credentials@v6
131112
with:
@@ -134,9 +115,34 @@ jobs:
134115
- name: Login to ECR
135116
id: login-ecr
136117
uses: aws-actions/amazon-ecr-login@v2
137-
- name: Load Docker image
138-
run: docker load -i image.tar
139-
- name: Tag Docker image
140-
run: docker tag mavis-${{ matrix.image_type }}:latest "${{ steps.login-ecr.outputs.registry }}/mavis/${{ matrix.image_type }}":"$git_ref"
141-
- name: Push Docker image
142-
run: docker push "${{ steps.login-ecr.outputs.registry }}/mavis/${{ matrix.image_type }}":"$git_ref"
118+
- name: Set up Docker Buildx
119+
uses: docker/setup-buildx-action@v4
120+
# yamllint disable rule:line-length
121+
- name: Build and push webapp image
122+
if: needs.check-image-presence.outputs.webapp-build-needed == 'true'
123+
uses: docker/build-push-action@v7
124+
with:
125+
context: .
126+
push: true
127+
tags: ${{ steps.login-ecr.outputs.registry }}/mavis/webapp:${{ env.git_ref }}
128+
cache-from:
129+
type=registry,ref=${{ steps.login-ecr.outputs.registry }}/mavis/webapp:buildcache
130+
cache-to:
131+
type=registry,ref=${{ steps.login-ecr.outputs.registry
132+
}}/mavis/webapp:buildcache,mode=max,image-manifest=true,oci-mediatypes=true
133+
- name: Build and push ops image
134+
if: needs.check-image-presence.outputs.ops-build-needed == 'true'
135+
uses: docker/build-push-action@v7
136+
with:
137+
context: .
138+
file: ops.Dockerfile
139+
push: true
140+
tags: ${{ steps.login-ecr.outputs.registry }}/mavis/ops:${{ env.git_ref }}
141+
build-args: |
142+
REPOSITORY=${{ steps.login-ecr.outputs.registry }}/mavis/webapp
143+
IMAGE_TAG=${{ env.git_ref }}
144+
cache-from: type=registry,ref=${{ steps.login-ecr.outputs.registry }}/mavis/ops:buildcache
145+
cache-to:
146+
type=registry,ref=${{ steps.login-ecr.outputs.registry
147+
}}/mavis/ops:buildcache,mode=max,image-manifest=true,oci-mediatypes=true
148+
# yamllint enable rule:line-length
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Call end-to-end tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
cross_service_tests:
7+
required: true
8+
type: boolean
9+
endpoint:
10+
required: true
11+
type: string
12+
github_ref:
13+
required: true
14+
type: string
15+
secrets:
16+
HTTP_AUTH_TOKEN_FOR_TESTS:
17+
description: HTTP Basic Auth token for the environment under test
18+
required: false
19+
MAVIS_TESTING_REPO_ACCESS_TOKEN:
20+
description: Access token for the manage-vaccinations-in-schools-testing repository
21+
required: false
22+
IMMS_API_KEY_FOR_TESTS:
23+
description: API key to use NHS Immunisations API
24+
required: false
25+
IMMS_API_KID_FOR_TESTS:
26+
description: API KID to use NHS Immunisations API
27+
required: false
28+
IMMS_API_PEM_FOR_TESTS:
29+
description: API PEM to use NHS Immunisations API
30+
required: false
31+
32+
jobs:
33+
call-tests:
34+
# yamllint disable-line rule:line-length
35+
uses: NHSDigital/manage-vaccinations-in-schools-testing/.github/workflows/end-to-end-tests.yaml@main
36+
with:
37+
cross_service_tests: ${{ inputs.cross_service_tests }}
38+
github_ref: ${{ inputs.github_ref }}
39+
endpoint: ${{ inputs.endpoint }}
40+
secrets:
41+
HTTP_AUTH_TOKEN_FOR_TESTS: ${{ secrets.HTTP_AUTH_TOKEN_FOR_TESTS }}
42+
MAVIS_TESTING_REPO_ACCESS_TOKEN: ${{ secrets.MAVIS_TESTING_REPO_ACCESS_TOKEN }}
43+
IMMS_API_KEY: ${{ secrets.IMMS_API_KEY_FOR_TESTS }}
44+
IMMS_API_KID: ${{ secrets.IMMS_API_KID_FOR_TESTS }}
45+
IMMS_API_PEM: ${{ secrets.IMMS_API_PEM_FOR_TESTS }}

.github/workflows/continuous-deployment.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
id-token: write
1313
uses: ./.github/workflows/test.yml
1414
deploy:
15-
needs: test
1615
strategy:
1716
fail-fast: false
1817
matrix:
@@ -23,18 +22,29 @@ jobs:
2322
with:
2423
environment: ${{ matrix.environment }}
2524
server_types: all
25+
run_pre_deploy_migrations: false
26+
end-to-end-tests:
27+
needs: [deploy]
28+
uses: ./.github/workflows/call-end-to-end-tests.yml
29+
secrets: inherit
30+
with:
31+
cross_service_tests: true
32+
endpoint: https://qa.mavistesting.com
33+
github_ref: main
2634
slack-notification:
27-
needs: [deploy, test]
35+
needs: [deploy, test, end-to-end-tests]
2836
runs-on: ubuntu-latest
2937
permissions: {}
3038
if: ${{ !cancelled() }}
3139
steps:
32-
- name: Send Slack notification
40+
- name: Send Slack notification about failed deployment
3341
if: needs.test.result == 'failure' || needs.deploy.result == 'failure'
3442
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a
3543
with:
36-
webhook: ${{ secrets.SLACK_MAVIS_ALERTS_WEBHOOK_URL }}
44+
webhook: ${{ secrets.SLACK_MAVIS_TECH_WEBHOOK_URL }}
3745
webhook-type: incoming-webhook
46+
errors: true
47+
# yamllint disable rule:line-length
3848
payload: |
3949
text: ":rotating_light: Continuous Deployment failed :rotating_light:"
4050
blocks:
@@ -43,3 +53,21 @@ jobs:
4353
type: "mrkdwn"
4454
text: ":rotating_light: *Continuous Deployment failed* :rotating_light:\n\n \
4555
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow run>"
56+
# yamllint enable rule:line-length
57+
- name: Send Slack notification about failed E2E tests
58+
if: needs.end-to-end-tests.result == 'failure'
59+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a
60+
with:
61+
webhook: ${{ secrets.SLACK_MAVIS_TECH_WEBHOOK_URL }}
62+
webhook-type: incoming-webhook
63+
errors: true
64+
# yamllint disable rule:line-length
65+
payload: |
66+
text: ":rotating_light: E2E tests failed on next :rotating_light:"
67+
blocks:
68+
- type: "section"
69+
text:
70+
type: "mrkdwn"
71+
text: ":rotating_light: *E2E tests failed on next* :rotating_light:\n\n \
72+
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow run>"
73+
# yamllint enable rule:line-length

.github/workflows/create_dockerized_db.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,18 @@ jobs:
7272
- name: Login to ECR
7373
id: login-ecr
7474
uses: aws-actions/amazon-ecr-login@v2
75+
# yamllint disable rule:line-length
7576
- name: get github ref short
7677
id: github-ref
7778
run: |
78-
git_ref=$(git rev-parse ${{ inputs.github_ref || github.ref_name == 'next' && 'origin/next' || github.ref_name }} )
79+
git_ref=$(git rev-parse ${{ inputs.github_ref || github.ref_name == 'next' && 'origin/next' || github.ref_name }})
7980
echo "ref=$git_ref" >> "$GITHUB_OUTPUT"
8081
- name: Commit postgres container with database
81-
run: |
82-
docker commit database "${{ steps.login-ecr.outputs.registry }}/mavis/development/postgres_db:${{ steps.github-ref.outputs.ref }}"
82+
run: >-
83+
docker commit database "${{ steps.login-ecr.outputs.registry
84+
}}/mavis/development/postgres_db:${{ steps.github-ref.outputs.ref }}"
8385
- name: Push image
84-
run: docker push "${{ steps.login-ecr.outputs.registry }}/mavis/development/postgres_db:${{ steps.github-ref.outputs.ref }}"
86+
run: >-
87+
docker push "${{ steps.login-ecr.outputs.registry }}/mavis/development/postgres_db:${{
88+
steps.github-ref.outputs.ref }}"
89+
# yamllint enable rule:line-length

.github/workflows/data-replication-pipeline.yml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Deploy data replication
2-
run-name: Deploy data replication from ${{ inputs.git_ref_to_deploy || github.ref_name }} to ${{ inputs.environment }}
2+
run-name: >-
3+
Deploy data replication from ${{ inputs.git_ref_to_deploy || github.ref_name }} to ${{
4+
inputs.environment }}
35
46
on:
57
workflow_dispatch:
@@ -16,10 +18,10 @@ on:
1618
- sandbox-alpha
1719
- sandbox-beta
1820
git_ref_to_deploy:
19-
description:
20-
| # Use blank unicode character (U+2800) to force line-break
21+
description: | # Use blank unicode character (U+2800) to force line-break
2122
Use code from: ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
22-
(Git ref to deploy, for example, a tag, branch name or commit SHA. Will use workflow ref if not provided.)
23+
(Git ref to deploy, for example, a tag, branch name or commit SHA. Will use workflow ref
24+
if not provided.)
2325
type: string
2426
workflow_call:
2527
inputs:
@@ -37,9 +39,10 @@ permissions: {}
3739
env:
3840
environment: ${{ inputs.environment }}
3941
git_ref_to_deploy: ${{ inputs.git_ref_to_deploy || github.sha }}
40-
aws_role: ${{ inputs.environment == 'production'
41-
&& 'arn:aws:iam::820242920762:role/GithubDeployDataReplicationInfrastructure'
42-
|| 'arn:aws:iam::393416225559:role/GithubDeployDataReplicationInfrastructure' }}
42+
aws_role:
43+
${{ inputs.environment == 'production' &&
44+
'arn:aws:iam::820242920762:role/GithubDeployDataReplicationInfrastructure' ||
45+
'arn:aws:iam::393416225559:role/GithubDeployDataReplicationInfrastructure' }}
4346
aws_account_id: ${{ inputs.environment == 'production' && '820242920762' || '393416225559' }}
4447

4548
concurrency:
@@ -124,12 +127,18 @@ jobs:
124127
id: create-task-definition
125128
uses: aws-actions/amazon-ecs-render-task-definition@v1
126129
with:
127-
task-definition-family: "mavis-data-replication-task-definition-${{ inputs.environment }}-template"
128-
container-name: "application"
129-
image: "${{ env.aws_account_id }}.dkr.ecr.eu-west-2.amazonaws.com/mavis/webapp@${{ steps.get-image-digest.outputs.digest }}"
130+
task-definition-family:
131+
mavis-data-replication-task-definition-${{ inputs.environment }}-template
132+
container-name: application
133+
# yamllint disable-line rule:line-length
134+
image:
135+
${{ env.aws_account_id }}.dkr.ecr.eu-west-2.amazonaws.com/mavis/webapp@${{
136+
steps.get-image-digest.outputs.digest }}
130137
environment-variables: ${{ steps.parse-environment-variables.outputs.parsed_env_vars }}
131138
- name: Rename task definition file
132-
run: mv ${{ steps.create-task-definition.outputs.task-definition }} ${{ runner.temp }}/data-replication-task-definition.json
139+
run: >-
140+
mv ${{ steps.create-task-definition.outputs.task-definition }} ${{ runner.temp
141+
}}/data-replication-task-definition.json
133142
- name: Upload artifact for data-replication task definition
134143
uses: actions/upload-artifact@v7
135144
with:
@@ -148,6 +157,7 @@ jobs:
148157
with:
149158
webhook: ${{ secrets.SLACK_MAVIS_TECH_WEBHOOK_URL }}
150159
webhook-type: incoming-webhook
160+
# yamllint disable rule:line-length
151161
payload: |
152162
text: ":hourglass: Approval required :hourglass:"
153163
blocks:
@@ -161,6 +171,7 @@ jobs:
161171
text: "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow run>"
162172
- type: "mrkdwn"
163173
text: "*Triggered by:*\n${{ github.actor }}"
174+
# yamllint enable rule:line-length
164175

165176
approve-deployments:
166177
name: Wait for approval if required
@@ -202,6 +213,7 @@ jobs:
202213
force-new-deployment: true
203214
wait-for-service-stability: true
204215
- name: Check if deployment was successful
216+
# yamllint disable rule:line-length
205217
run: |
206218
current_task_definition_arn=$(aws ecs describe-services --cluster "mavis-$environment-data-replication" --services "mavis-$environment-data-replication" --query services[0].deployments[0].taskDefinition | jq -r ".")
207219
new_task_definition_arn=${{ steps.ecs-deploy.outputs.task-definition-arn }}
@@ -211,3 +223,4 @@ jobs:
211223
echo "Task definition arns don't match, likely due to a rollback to the previous version. Deployment failed."
212224
exit 1
213225
fi
226+
# yamllint enable rule:line-length

0 commit comments

Comments
 (0)