Skip to content

Commit 0f6b63e

Browse files
committed
CCM-11938: build specification artefacts
1 parent 2d3d128 commit 0f6b63e

File tree

6 files changed

+137
-3
lines changed

6 files changed

+137
-3
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Build Proxies"
2+
description: "Build an OAS file with sandbox settings"
3+
inputs:
4+
pr_number:
5+
description: "Sandbox tag, one of: pr number, release tag, or latest"
6+
required: true
7+
8+
runs:
9+
using: composite
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Build sandbox oas
16+
working-directory: .
17+
shell: bash
18+
run: |
19+
make build-json-oas-spec APIM_ENV=sandbox
20+
21+
- name: Generate Sandbox Tag
22+
shell: bash
23+
run: |
24+
if [ -n "${{ github.event.release.tag_name }}" ]; then
25+
echo "SANDBOX_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
26+
elseif [ -n "${{ inputs.pr_number }}" ]; then
27+
echo "SANDBOX_TAG=pr${{ inputs.pr_number }}" >> $GITHUB_ENV
28+
else
29+
echo "SANDBOX_TAG=latest" >> $GITHUB_ENV
30+
fi
31+
32+
- name: Set docker tag
33+
shell: bash
34+
run: |
35+
jq --arg newtag "$SANDBOX_TAG" '.["x-nhsd-apim"].target.containers[0].image.tag = $newtag' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
36+
37+
- name: Rename artefact
38+
shell: bash
39+
run: |
40+
mv build/notify-supplier.json build/notify-supplier-sandbox.json
41+
42+
- name: Upload Sandbox Specification
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: api-specification-sandbox
46+
path: ./build/notify-supplier-sandbox.json
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "Build Proxies"
2+
description: "Build an OAS file with sandbox settings"
3+
inputs:
4+
apim_env:
5+
description: "APIM Target environment: internal-dev, internal-dev-sandbox, int, prod"
6+
required: true
7+
backend_account:
8+
description: "The backend target account: dev, nonprod, prod"
9+
required: true
10+
pr_number:
11+
description: "Sandbox tag, one of: pr number, release tag, or latest"
12+
required: true
13+
api_name:
14+
description: "The instance name of the API in APIM"
15+
required: true
16+
17+
runs:
18+
using: composite
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 24
27+
28+
- name: Npm install
29+
working-directory: .
30+
run: npm ci
31+
shell: bash
32+
33+
- name: Determing backend env
34+
shell: bash
35+
run: |
36+
if [ -n "${{ inputs.pr_number }}" ]; then
37+
echo "BACKEND_ENV=pr${{ inputs.pr_number }}" >> $GITHUB_ENV
38+
else
39+
echo "BACKEND_ENV=main" >> $GITHUB_ENV
40+
fi
41+
42+
- name: Setup Proxy Name and target
43+
shell: bash
44+
run: |
45+
echo "INSTANCE=${{ inputs.api_name }}-$BACKEND_ENV" >> $GITHUB_ENV
46+
echo "MTLS_NAME=notify-supplier-mtls-$BACKEND_ENV" >> $GITHUB_ENV
47+
echo "TARGET=https://$BACKEND_ENV.suppliers.${{ inputs.backend_account }}.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
48+
49+
- name: Build oas for environment
50+
working-directory: .
51+
shell: bash
52+
run: |
53+
make build-json-oas-spec APIM_ENV=${{ inputs.apim_env }}
54+
55+
- name: Set target and cert
56+
shell: bash
57+
run: |
58+
jq --arg newurl "$TARGET" '.["x-nhsd-apim"].target.url = $newurl' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
59+
jq --arg newmtls "$MTLS_NAME" '.["x-nhsd-apim"].target.security.secret = $newmtls' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
60+
61+
- name: Rename artefact
62+
shell: bash
63+
run: |
64+
mv build/notify-supplier.json build/notify-supplier-${{ inputs.apim-env }}.json
65+
66+
- name: Upload Sandbox Specification
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: api-specification
70+
path: ./build/notify-supplier-${{ inputs.apim-env }}.json

.github/workflows/stage-3-build.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,25 @@ jobs:
8888
with:
8989
version: "${{ inputs.version }}"
9090

91+
artefact-specifications:
92+
name: "Build Open API Specifications"
93+
runs-on: ubuntu-latest
94+
timeout-minutes: 10
95+
steps:
96+
- name: "Checkout code"
97+
uses: actions/checkout@v4
98+
- name: "Build sandbox"
99+
uses: ./.github/actions/build-oas-sandbox
100+
with:
101+
pr_number: "${{ inputs.pr_number }}"
102+
- name: "Build environment specification"
103+
uses: ./.github/actions/build-oas
104+
with:
105+
apim_env: "internal-dev"
106+
backend_account: "dev"
107+
pr_number: "${{ inputs.pr_number }}"
108+
api_name: "nhs-notify-supplier"
109+
91110
artefact-proxies:
92111
name: "Build proxies"
93112
runs-on: ubuntu-latest

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
"serve-html-docs": "npx serve sdk/html -p 3050",
6565
"serve-oas": "redocly preview -p 5001 -d specification/api",
6666
"serve-swagger-docs": "npx serve sdk/swagger -p 3051",
67-
"start": "npm run start --workspace frontend",
6867
"test:unit": "npm run test:unit --workspaces",
6968
"typecheck": "npm run typecheck --workspaces"
7069
},

specification/api/components/x-nhsd-apim/target-internal-dev-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ healthcheck: /_status
33
url: https://suppliers.dev.nhsnotify.national.nhs.uk
44
security:
55
type: mtls
6-
secret: nhs-notify-supplier-mtls
6+
secret: nhs-notify-supplier-mtls-main

specification/api/components/x-nhsd-apim/target-internal-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ healthcheck: /_status
33
url: https://suppliers.dev.nhsnotify.national.nhs.uk
44
security:
55
type: mtls
6-
secret: nhs-notify-supplier-mtls
6+
secret: nhs-notify-supplier-mtls-main

0 commit comments

Comments
 (0)