Skip to content

Commit 8f05b36

Browse files
committed
Merge remote-tracking branch 'origin/aea-6516-stateless-cdk' into aea-6515-stateful-cdk
2 parents a817268 + 983cd09 commit 8f05b36

24 files changed

Lines changed: 3568 additions & 1551 deletions
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Install dependencies"
2+
description: "Install dependencies defined in .tool-versions using asdf and npm packages"
3+
4+
inputs:
5+
npm-required:
6+
description: "Set to true if npm dependencies are already installed"
7+
required: false
8+
default: "true"
9+
GITHUB_TOKEN:
10+
description: "GitHub token to access private npm packages"
11+
required: true
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Setting up .npmrc
17+
shell: bash
18+
env:
19+
NODE_AUTH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
20+
run: |
21+
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
22+
echo "@nhsdigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
23+
24+
- name: Run make install
25+
if: inputs.npm-required == 'true'
26+
shell: bash
27+
run: |
28+
make install-node
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: cdk package code
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
BRANCH_NAME:
7+
required: true
8+
type: string
9+
VERSION_NUMBER:
10+
required: true
11+
type: string
12+
COMMIT_ID:
13+
required: true
14+
type: string
15+
pinned_image:
16+
required: true
17+
type: string
18+
19+
permissions: {}
20+
21+
jobs:
22+
package_code:
23+
runs-on: ubuntu-22.04
24+
container:
25+
image: ${{ inputs.pinned_image }}
26+
options: --user 1001:1001 --group-add 128
27+
defaults:
28+
run:
29+
shell: bash
30+
permissions:
31+
id-token: write
32+
contents: read
33+
packages: read
34+
steps:
35+
- name: copy .tool-versions
36+
run: |
37+
cp /home/vscode/.tool-versions "$HOME/.tool-versions"
38+
- name: Checkout code
39+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
40+
with:
41+
ref: ${{ inputs.BRANCH_NAME }}
42+
persist-credentials: false
43+
44+
- name: install dependencies
45+
uses: ./.github/actions/install_dependencies
46+
with:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: make compile
50+
run: make compile
51+
52+
- name: "Tar files"
53+
run: |
54+
tar -rf artifact.tar \
55+
.github \
56+
packages \
57+
node_modules \
58+
package.json \
59+
package-lock.json \
60+
tsconfig.defaults.json
61+
62+
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
63+
name: upload build artifact
64+
with:
65+
name: build_artifact
66+
path: artifact.tar
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: cdk release code
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
BRANCH_NAME:
7+
required: true
8+
type: string
9+
STACK_NAME:
10+
required: true
11+
type: string
12+
AWS_ENVIRONMENT:
13+
required: true
14+
type: string
15+
VERSION_NUMBER:
16+
required: true
17+
type: string
18+
COMMIT_ID:
19+
required: true
20+
type: string
21+
CDK_APP_NAME:
22+
required: true
23+
type: string
24+
LOG_RETENTION_IN_DAYS:
25+
required: true
26+
type: string
27+
LOG_LEVEL:
28+
type: string
29+
IS_PULL_REQUEST:
30+
type: boolean
31+
required: true
32+
TRUSTSTORE_FILE:
33+
type: string
34+
required: true
35+
FORWARD_CSOC_LOGS:
36+
type: boolean
37+
required: true
38+
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE:
39+
type: boolean
40+
required: true
41+
EXPOSE_GET_STATUS_UPDATES:
42+
type: boolean
43+
required: true
44+
SAM_STACK_NAME:
45+
type: string
46+
required: true
47+
ENABLE_POST_DATED_NOTIFICATIONS:
48+
type: boolean
49+
required: true
50+
REQUIRE_APPLICATION_NAME:
51+
type: boolean
52+
required: true
53+
ENABLE_BACKUP:
54+
type: boolean
55+
required: true
56+
pinned_image:
57+
required: true
58+
type: string
59+
secrets:
60+
CLOUD_FORMATION_DEPLOY_ROLE:
61+
required: true
62+
permissions: {}
63+
64+
jobs:
65+
release_code:
66+
runs-on: ubuntu-22.04
67+
environment: ${{ inputs.AWS_ENVIRONMENT }}
68+
container:
69+
image: ${{ inputs.pinned_image }}
70+
options: --user 1001:1001 --group-add 128
71+
defaults:
72+
run:
73+
shell: bash
74+
name: deploy cdk app ${{ inputs.CDK_APP_NAME }}
75+
permissions:
76+
id-token: write
77+
contents: read
78+
79+
steps:
80+
- name: copy .tool-versions
81+
run: |
82+
cp /home/vscode/.tool-versions "$HOME/.tool-versions"
83+
84+
- name: build_artifact download
85+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
86+
with:
87+
name: build_artifact
88+
89+
- name: extract build_artifact
90+
run: tar -xf artifact.tar
91+
92+
- name: install dependencies
93+
uses: ./.github/actions/install_dependencies
94+
with:
95+
npm-required: false
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
98+
- name: Configure AWS Credentials
99+
id: connect-aws-deploy
100+
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
101+
with:
102+
aws-region: eu-west-2
103+
role-to-assume: ${{ secrets.CLOUD_FORMATION_DEPLOY_ROLE }}
104+
role-session-name: psu-deployment
105+
106+
- name: Deploy AWS infrastructure and code
107+
run: npm run cdk-deploy --workspace packages/cdk
108+
shell: bash
109+
env:
110+
CDK_APP_NAME: "${{ inputs.CDK_APP_NAME }}"
111+
CDK_CONFIG_stackName: "${{ inputs.STACK_NAME }}"
112+
CDK_CONFIG_versionNumber: "${{ inputs.VERSION_NUMBER }}"
113+
CDK_CONFIG_commitId: "${{ inputs.COMMIT_ID }}"
114+
CDK_CONFIG_isPullRequest: "${{ inputs.IS_PULL_REQUEST }}"
115+
CDK_CONFIG_environment: "${{ inputs.AWS_ENVIRONMENT }}"
116+
CDK_CONFIG_logRetentionInDays: "${{ inputs.LOG_RETENTION_IN_DAYS }}"
117+
CDK_CONFIG_logLevel: "${{ inputs.LOG_LEVEL }}"
118+
CDK_CONFIG_trustStoreFile: "${{ inputs.TRUSTSTORE_FILE }}"
119+
CDK_CONFIG_forwardCsocLogs: "${{ inputs.FORWARD_CSOC_LOGS }}"
120+
CDK_CONFIG_deployCheckPrescriptionStatusUpdate: "${{ inputs.DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE }}"
121+
CDK_CONFIG_exposeGetStatusUpdates: "${{ inputs.EXPOSE_GET_STATUS_UPDATES }}"
122+
CDK_CONFIG_samStackName: "${{ inputs.SAM_STACK_NAME }}"
123+
CDK_CONFIG_enablePostDatedNotifications: "${{ inputs.ENABLE_POST_DATED_NOTIFICATIONS }}"
124+
CDK_CONFIG_requireApplicationName: "${{ inputs.REQUIRE_APPLICATION_NAME }}"
125+
CDK_CONFIG_enableBackup: "${{ inputs.ENABLE_BACKUP }}"
126+
REQUIRE_APPROVAL: "never"
127+
128+
# later, there will be API deployment steps c.f. https://github.com/NHSDigital/electronic-prescription-service-clinical-prescription-tracker/blob/main/.github/workflows/cdk_release_code.yml

.github/workflows/ci.yml

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,48 @@ jobs:
5151
branch_name: main
5252
tag_format: ${{ needs.get_config_values.outputs.tag_format }}
5353

54-
package_code:
54+
cdk_package_code:
55+
needs: [get_commit_id, tag_release, get_config_values]
56+
uses: ./.github/workflows/cdk_package_code.yml
57+
permissions:
58+
contents: read
59+
packages: read
60+
id-token: write
61+
with:
62+
BRANCH_NAME: main
63+
VERSION_NUMBER: ${{ needs.tag_release.outputs.version_tag }}
64+
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
65+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
66+
67+
cdk_release_dev:
68+
needs: [cdk_package_code, get_commit_id, tag_release, get_config_values]
69+
uses: ./.github/workflows/cdk_release_code.yml
70+
permissions:
71+
contents: write
72+
id-token: write
73+
with:
74+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
75+
BRANCH_NAME: main
76+
STACK_NAME: psu-cdk
77+
AWS_ENVIRONMENT: dev
78+
VERSION_NUMBER: ${{ needs.tag_release.outputs.version_tag }}
79+
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
80+
CDK_APP_NAME: PsuStatelessApp
81+
LOG_RETENTION_IN_DAYS: "30"
82+
LOG_LEVEL: DEBUG
83+
IS_PULL_REQUEST: false
84+
TRUSTSTORE_FILE: psu-truststore.pem
85+
FORWARD_CSOC_LOGS: false
86+
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
87+
EXPOSE_GET_STATUS_UPDATES: false
88+
SAM_STACK_NAME: psu
89+
ENABLE_POST_DATED_NOTIFICATIONS: true
90+
REQUIRE_APPLICATION_NAME: false
91+
ENABLE_BACKUP: true
92+
secrets:
93+
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
94+
95+
sam_package_code:
5596
needs: [tag_release, get_config_values]
5697
uses: ./.github/workflows/run_package_code_and_api.yml
5798
permissions:
@@ -62,7 +103,7 @@ jobs:
62103
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
63104

64105
release_dev:
65-
needs: [tag_release, package_code, get_commit_id, get_config_values]
106+
needs: [tag_release, sam_package_code, get_commit_id, get_config_values]
66107
uses: ./.github/workflows/run_release_code_and_api.yml
67108
permissions:
68109
contents: write
@@ -111,7 +152,7 @@ jobs:
111152
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}
112153

113154
release_sandbox_dev:
114-
needs: [tag_release, package_code, get_commit_id, get_config_values]
155+
needs: [tag_release, sam_package_code, get_commit_id, get_config_values]
115156
uses: ./.github/workflows/run_release_code_and_api.yml
116157
permissions:
117158
contents: write
@@ -155,7 +196,13 @@ jobs:
155196

156197
release_qa:
157198
needs:
158-
[tag_release, release_dev, package_code, get_commit_id, get_config_values]
199+
[
200+
tag_release,
201+
release_dev,
202+
sam_package_code,
203+
get_commit_id,
204+
get_config_values,
205+
]
159206
uses: ./.github/workflows/run_release_code_and_api.yml
160207
permissions:
161208
contents: write

.github/workflows/pull_request.yml

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,49 @@ jobs:
9393
run: |
9494
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
9595
96-
package_code:
96+
cdk_package_code:
97+
needs: [get_issue_number, get_commit_id, get_config_values]
98+
uses: ./.github/workflows/cdk_package_code.yml
99+
permissions:
100+
contents: read
101+
packages: read
102+
id-token: write
103+
with:
104+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
105+
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
106+
VERSION_NUMBER: PR-${{ needs.get_issue_number.outputs.issue_number }}
107+
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
108+
109+
cdk_release_code:
110+
needs:
111+
[get_issue_number, cdk_package_code, get_commit_id, get_config_values]
112+
uses: ./.github/workflows/cdk_release_code.yml
113+
permissions:
114+
contents: write
115+
id-token: write
116+
with:
117+
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
118+
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
119+
STACK_NAME: psu-cdk-pr-${{needs.get_issue_number.outputs.issue_number}}
120+
AWS_ENVIRONMENT: dev
121+
VERSION_NUMBER: PR-${{ needs.get_issue_number.outputs.issue_number }}
122+
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
123+
CDK_APP_NAME: PsuStatelessApp
124+
LOG_RETENTION_IN_DAYS: "30"
125+
LOG_LEVEL: DEBUG
126+
IS_PULL_REQUEST: true
127+
TRUSTSTORE_FILE: psu-truststore.pem
128+
FORWARD_CSOC_LOGS: false
129+
DEPLOY_CHECK_PRESCRIPTION_STATUS_UPDATE: true
130+
EXPOSE_GET_STATUS_UPDATES: false
131+
SAM_STACK_NAME: psu-pr-${{needs.get_issue_number.outputs.issue_number}}
132+
ENABLE_POST_DATED_NOTIFICATIONS: true
133+
REQUIRE_APPLICATION_NAME: false
134+
ENABLE_BACKUP: false
135+
secrets:
136+
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
137+
138+
sam_package_code:
97139
needs: [get_issue_number, get_config_values]
98140
uses: ./.github/workflows/run_package_code_and_api.yml
99141
permissions:
@@ -103,8 +145,9 @@ jobs:
103145
with:
104146
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
105147

106-
release_code:
107-
needs: [get_issue_number, package_code, get_commit_id, get_config_values]
148+
sam_release_code:
149+
needs:
150+
[get_issue_number, sam_package_code, get_commit_id, get_config_values]
108151
uses: ./.github/workflows/run_release_code_and_api.yml
109152
permissions:
110153
contents: write
@@ -153,7 +196,8 @@ jobs:
153196
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}
154197

155198
release_sandbox_code:
156-
needs: [get_issue_number, package_code, get_commit_id, get_config_values]
199+
needs:
200+
[get_issue_number, sam_package_code, get_commit_id, get_config_values]
157201
uses: ./.github/workflows/run_release_code_and_api.yml
158202
permissions:
159203
contents: write

0 commit comments

Comments
 (0)