Skip to content

Commit 347c9a3

Browse files
committed
Merge branch 'main' into feature/CCM-13615_letter-status-source
2 parents 7cc67bb + 0517359 commit 347c9a3

164 files changed

Lines changed: 16293 additions & 18977 deletions

File tree

Some content is hidden

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

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
},
8484
"mounts": [
8585
"source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,consistency=cached",
86-
"source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached"
86+
"source=${localEnv:HOME}/.aws,target=/home/vscode/.aws,type=bind,consistency=cached",
87+
"source=${localEnv:HOME}/.npmrc,target=/home/vscode/.npmrc,type=bind,consistency=cached"
8788
],
8889
"name": "Devcontainer",
8990
"postCreateCommand": "scripts/devcontainer/postcreatecommand.sh"

.env.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ENVIRONMENT=$ENV_NAME
2+
API_KEY=
3+
HEADERAUTH=
4+
PR_NUMBER=prxx # remove if needs to run against main
5+
NHSD_APIM_TOKEN=

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- [ ] I have added tests to cover my changes
2626
- [ ] I have updated the documentation accordingly
2727
- [ ] This PR is a result of pair or mob programming
28+
- [ ] If I have used the 'skip-trivy-package' label I have done so responsibly and in the knowledge that this is being fixed as part of a separate ticket/PR.
2829

2930
---
3031

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Acceptance tests
2+
description: "Run acceptance tests for this repo"
3+
4+
inputs:
5+
testType:
6+
description: Type of test to run
7+
required: true
8+
9+
targetEnvironment:
10+
description: Name of the environment under test
11+
required: true
12+
13+
targetAccountGroup:
14+
description: Name of the account group under test
15+
default: nhs-notify-template-management-dev
16+
required: true
17+
18+
targetComponent:
19+
description: Name of the component under test
20+
required: true
21+
22+
runs:
23+
using: "composite"
24+
25+
steps:
26+
- name: Fetch terraform output
27+
uses: actions/download-artifact@v5
28+
with:
29+
name: terraform-output-${{ inputs.targetComponent }}
30+
31+
- name: Get Node version
32+
id: nodejs_version
33+
shell: bash
34+
run: |
35+
echo "nodejs_version=$(grep "^nodejs\s" .tool-versions | cut -f2 -d' ')" >> $GITHUB_OUTPUT
36+
37+
- name: "Repo setup"
38+
uses: ./.github/actions/node-install
39+
with:
40+
node-version: ${{ steps.nodejs_version.outputs.nodejs_version }}
41+
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
42+
43+
- name: "Set PR NUMBER"
44+
shell: bash
45+
run: |
46+
echo "PR_NUMBER=${{ inputs.targetEnvironment }}" >> $GITHUB_ENV
47+
48+
- name: Run test - ${{ inputs.testType }}
49+
shell: bash
50+
run: |
51+
make test-${{ inputs.testType }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: "Build OAS Spec"
2+
description: "Build OAS Spec"
3+
4+
inputs:
5+
version:
6+
description: "Version number"
7+
required: true
8+
apimEnv:
9+
description: "APIM environment"
10+
required: true
11+
buildSandbox:
12+
description: "Whether to build the sandbox OAS spec"
13+
required: false
14+
default: false
15+
nodejs_version:
16+
description: "Node.js version, set by the CI/CD pipeline workflow"
17+
required: true
18+
NODE_AUTH_TOKEN:
19+
description: "Token for access to github package registry"
20+
required: true
21+
22+
runs:
23+
using: composite
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: ${{ inputs.nodejs_version }}
31+
registry-url: 'https://npm.pkg.github.com'
32+
33+
- name: "Cache node_modules"
34+
uses: actions/cache@v4
35+
with:
36+
path: |
37+
**/node_modules
38+
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
39+
restore-keys: |
40+
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
41+
42+
- name: Npm install
43+
working-directory: .
44+
env:
45+
NODE_AUTH_TOKEN: ${{ inputs.NODE_AUTH_TOKEN }}
46+
run: npm ci
47+
shell: bash
48+
49+
- name: Build ${{ inputs.apimEnv }} oas
50+
working-directory: .
51+
env:
52+
APIM_ENV: ${{ inputs.apimEnv }}
53+
shell: bash
54+
run: |
55+
if [ ${{ env.APIM_ENV }} == "internal-dev-sandbox" ] && [ ${{ inputs.buildSandbox }} == true ]
56+
then
57+
echo "Building sandbox OAS spec"
58+
make build-json-oas-spec APIM_ENV=sandbox
59+
else
60+
echo "Building env specific OAS spec"
61+
make build-yml-oas-spec APIM_ENV=${{ env.APIM_ENV }}
62+
fi
63+
64+
- name: Upload API OAS specification artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
path: "build"
68+
name: api-oas-specification-${{ inputs.apimEnv }}${{ inputs.version != '' && format('-{0}', inputs.version) || '' }}

.github/actions/build-proxies/action.yml

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ inputs:
88
releaseVersion:
99
description: "Release, tag, branch, or commit ID to be used for deployment"
1010
required: true
11+
isRelease:
12+
description: "True if releaseVersion is a release tag (if set, downloads from release assets instead of workflow artifacts)"
13+
required: false
14+
default: false
1115
environment:
1216
description: "Deployment environment"
1317
required: true
@@ -25,39 +29,33 @@ inputs:
2529
description: "Name of the Component to deploy"
2630
required: true
2731
default: 'api'
28-
nodejs_version:
29-
description: "Node.js version, set by the CI/CD pipeline workflow"
30-
required: true
31-
NODE_AUTH_TOKEN:
32-
description: "Token for access to github package registry"
33-
required: true
3432

3533
runs:
3634
using: composite
3735

3836
steps:
39-
- name: Checkout
40-
uses: actions/checkout@v4
41-
- uses: actions/setup-node@v4
37+
- name: Download OAS Spec artifact from workflow
38+
if: ${{ inputs.isRelease == 'false' }}
39+
uses: actions/download-artifact@v4
4240
with:
43-
node-version: ${{ inputs.nodejs_version }}
44-
registry-url: 'https://npm.pkg.github.com'
45-
46-
- name: "Cache node_modules"
47-
uses: actions/cache@v4
48-
with:
49-
path: |
50-
**/node_modules
51-
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
52-
restore-keys: |
53-
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
41+
name: api-oas-specification-${{ inputs.apimEnv }}${{ inputs.version != '' && format('-{0}', inputs.version) || '' }}
42+
path: ./build
5443

55-
- name: Npm install
56-
working-directory: .
57-
env:
58-
NODE_AUTH_TOKEN: ${{ inputs.NODE_AUTH_TOKEN }}
59-
run: npm ci
44+
- name: Download OAS Spec artifact from release
45+
if: ${{ inputs.isRelease == 'true' }}
6046
shell: bash
47+
run: |
48+
mkdir ./build
49+
ASSET_PATTERN="api-oas-specification-${{ inputs.apimEnv }}-*.zip"
50+
gh release download "${{ inputs.releaseVersion }}" \
51+
--pattern "$ASSET_PATTERN" \
52+
--dir ./build
53+
# Unzip the downloaded file (there should be exactly one match)
54+
ASSET_FILE=$(ls ./build/api-oas-specification-${{ inputs.apimEnv }}-*.zip)
55+
unzip "$ASSET_FILE" -d ./build
56+
rm "$ASSET_FILE"
57+
env:
58+
GH_TOKEN: ${{ github.token }}
6159

6260
- name: Setup Proxy Name and target
6361
shell: bash
@@ -87,21 +85,10 @@ runs:
8785
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
8886
fi
8987
90-
- name: Build ${{ inputs.apimEnv }} oas
91-
working-directory: .
92-
env:
93-
APIM_ENV: ${{ inputs.apimEnv }}
88+
- name: Set APIM_ENV
9489
shell: bash
9590
run: |
96-
if [ ${{ env.APIM_ENV }} == "internal-dev-sandbox" ] && [ ${{ inputs.buildSandbox }} == true ]
97-
then
98-
echo "Building sandbox OAS spec"
99-
make build-json-oas-spec APIM_ENV=sandbox
100-
else
101-
echo "Building env specific OAS spec"
102-
make build-json-oas-spec APIM_ENV=${{ env.APIM_ENV }}
103-
fi
104-
91+
APIM_ENV="${{ inputs.apimEnv }}"
10592
if [[ $APIM_ENV == *-pr ]]; then
10693
echo "Removing pr suffix from APIM_ENV after building OAS and calling proxygen"
10794
APIM_ENV=$(echo "$APIM_ENV" | sed 's/-pr$//')

.github/actions/build-sdk/action.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ runs:
5555
run: |
5656
make build VERSION="${{ inputs.version }}"
5757
58-
- name: Upload API OAS specification artifact
59-
uses: actions/upload-artifact@v4
60-
with:
61-
path: "build"
62-
name: api-oas-specification-${{ inputs.version }}
63-
6458
- name: Upload html artifact
6559
uses: actions/upload-artifact@v4
6660
with:

.github/actions/test-types.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
"component"
3+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "Trivy IaC Scan"
2+
description: "Scan Terraform IaC using Trivy"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: "Trivy Terraform IaC Scan"
7+
shell: bash
8+
run: |
9+
components_exit_code=0
10+
modules_exit_code=0
11+
12+
./scripts/terraform/trivy-scan.sh --mode iac ./infrastructure/terraform/components || components_exit_code=$?
13+
./scripts/terraform/trivy-scan.sh --mode iac ./infrastructure/terraform/modules || modules_exit_code=$?
14+
15+
if [ $components_exit_code -ne 0 ] || [ $modules_exit_code -ne 0 ]; then
16+
echo "Trivy misconfigurations detected."
17+
exit 1
18+
fi
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "Trivy Package Scan"
2+
description: "Scan project packages using Trivy"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: "Trivy Package Scan"
7+
shell: bash
8+
run: |
9+
exit_code=0
10+
11+
./scripts/terraform/trivy-scan.sh --mode package . || exit_code=$?
12+
13+
if [ $exit_code -ne 0 ]; then
14+
echo "Trivy has detected package vulnerablilites. Please refer to https://nhsd-confluence.digital.nhs.uk/spaces/RIS/pages/1257636917/PLAT-KOP-012+-+Trivy+Pipeline+Vulnerability+Scanning+Exemption"
15+
exit 1
16+
fi

0 commit comments

Comments
 (0)