Skip to content

Commit 7a52947

Browse files
committed
Attempt to deploy an empty stack
1 parent af6f748 commit 7a52947

17 files changed

Lines changed: 2117 additions & 555 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: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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: download the get secrets lambda layer
53+
run: |
54+
make download-get-secrets-layer
55+
56+
- name: "Tar files"
57+
run: |
58+
tar -rf artifact.tar \
59+
.github \
60+
packages \
61+
node_modules \
62+
package.json \
63+
package-lock.json \
64+
tsconfig.defaults.json
65+
66+
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
67+
name: upload build artifact
68+
with:
69+
name: build_artifact
70+
path: artifact.tar
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
pinned_image:
33+
required: true
34+
type: string
35+
secrets:
36+
CLOUD_FORMATION_DEPLOY_ROLE:
37+
required: true
38+
permissions: {}
39+
40+
jobs:
41+
release_code:
42+
runs-on: ubuntu-22.04
43+
environment: ${{ inputs.AWS_ENVIRONMENT }}
44+
container:
45+
image: ${{ inputs.pinned_image }}
46+
options: --user 1001:1001 --group-add 128
47+
defaults:
48+
run:
49+
shell: bash
50+
name: deploy cdk app ${{ inputs.CDK_APP_NAME }}
51+
permissions:
52+
id-token: write
53+
contents: read
54+
55+
steps:
56+
- name: copy .tool-versions
57+
run: |
58+
cp /home/vscode/.tool-versions "$HOME/.tool-versions"
59+
60+
- name: build_artifact download
61+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
62+
with:
63+
name: build_artifact
64+
65+
- name: extract build_artifact
66+
run: tar -xf artifact.tar
67+
68+
- name: install dependencies
69+
uses: ./.github/actions/install_dependencies
70+
with:
71+
npm-required: false
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
74+
- name: Configure AWS Credentials
75+
id: connect-aws-deploy
76+
uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7
77+
with:
78+
aws-region: eu-west-2
79+
role-to-assume: ${{ secrets.CLOUD_FORMATION_DEPLOY_ROLE }}
80+
role-session-name: psu-deployment
81+
82+
- name: Deploy AWS infrastructure and code
83+
run: npm run cdk-deploy --workspace packages/cdk
84+
shell: bash
85+
env:
86+
CDK_APP_NAME: "${{ inputs.CDK_APP_NAME }}"
87+
CDK_CONFIG_stackName: "${{ inputs.STACK_NAME }}"
88+
CDK_CONFIG_versionNumber: "${{ inputs.VERSION_NUMBER }}"
89+
CDK_CONFIG_commitId: "${{ inputs.COMMIT_ID }}"
90+
CDK_CONFIG_isPullRequest: "${{ inputs.IS_PULL_REQUEST }}"
91+
CDK_CONFIG_environment: "${{ inputs.AWS_ENVIRONMENT }}"
92+
CDK_CONFIG_logRetentionInDays: "${{ inputs.LOG_RETENTION_IN_DAYS }}"
93+
CDK_CONFIG_logLevel: "${{ inputs.LOG_LEVEL }}"
94+
REQUIRE_APPROVAL: "never"
95+
96+
# 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: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,40 @@ 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+
secrets:
85+
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
86+
87+
sam_package_code:
5588
needs: [tag_release, get_config_values]
5689
uses: ./.github/workflows/run_package_code_and_api.yml
5790
permissions:
@@ -62,7 +95,7 @@ jobs:
6295
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
6396

6497
release_dev:
65-
needs: [tag_release, package_code, get_commit_id, get_config_values]
98+
needs: [tag_release, sam_package_code, get_commit_id, get_config_values]
6699
uses: ./.github/workflows/run_release_code_and_api.yml
67100
permissions:
68101
contents: write
@@ -111,7 +144,7 @@ jobs:
111144
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}
112145

113146
release_sandbox_dev:
114-
needs: [tag_release, package_code, get_commit_id, get_config_values]
147+
needs: [tag_release, sam_package_code, get_commit_id, get_config_values]
115148
uses: ./.github/workflows/run_release_code_and_api.yml
116149
permissions:
117150
contents: write
@@ -155,7 +188,13 @@ jobs:
155188

156189
release_qa:
157190
needs:
158-
[tag_release, release_dev, package_code, get_commit_id, get_config_values]
191+
[
192+
tag_release,
193+
release_dev,
194+
sam_package_code,
195+
get_commit_id,
196+
get_config_values,
197+
]
159198
uses: ./.github/workflows/run_release_code_and_api.yml
160199
permissions:
161200
contents: write

.github/workflows/pull_request.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,41 @@ 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+
secrets:
128+
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
129+
130+
sam_package_code:
97131
needs: [get_issue_number, get_config_values]
98132
uses: ./.github/workflows/run_package_code_and_api.yml
99133
permissions:
@@ -103,8 +137,9 @@ jobs:
103137
with:
104138
pinned_image: ${{ needs.get_config_values.outputs.pinned_image }}
105139

106-
release_code:
107-
needs: [get_issue_number, package_code, get_commit_id, get_config_values]
140+
sam_release_code:
141+
needs:
142+
[get_issue_number, sam_package_code, get_commit_id, get_config_values]
108143
uses: ./.github/workflows/run_release_code_and_api.yml
109144
permissions:
110145
contents: write
@@ -153,7 +188,8 @@ jobs:
153188
REGRESSION_TESTS_PEM: ${{ secrets.REGRESSION_TESTS_PEM }}
154189

155190
release_sandbox_code:
156-
needs: [get_issue_number, package_code, get_commit_id, get_config_values]
191+
needs:
192+
[get_issue_number, sam_package_code, get_commit_id, get_config_values]
157193
uses: ./.github/workflows/run_release_code_and_api.yml
158194
permissions:
159195
contents: write

0 commit comments

Comments
 (0)