Skip to content

Commit edb2c39

Browse files
Initial sandbox proxy deploy (#99)
1 parent fbf42cc commit edb2c39

Some content is hidden

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

64 files changed

+13564
-7388
lines changed

.devcontainer/devcontainer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"takumii.markdowntable",
4242
"tamasfe.even-better-toml",
4343
"tomoki1207.pdf",
44+
"vscjava.vscode-java-pack",
4445
"vscode-icons-team.vscode-icons",
4546
"vstirbu.vscode-mermaid-preview",
4647
"wayou.vscode-todo-highlight",
@@ -89,6 +90,9 @@
8990
"version": "8.0"
9091
},
9192
"ghcr.io/devcontainers/features/go:1": {},
93+
"ghcr.io/devcontainers/features/java:1": {
94+
"version": "17"
95+
},
9296
"ghcr.io/devcontainers/features/node:1": {},
9397
"ghcr.io/devcontainers/features/python:1": {},
9498
"ghcr.io/devcontainers/features/ruby:1": {}

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ runs:
1919
run: npm ci
2020
shell: bash
2121

22-
- name: Build oas
23-
working-directory: .
24-
shell: bash
25-
run: |
26-
make publish-oas
27-
2822
- name: Setup Proxy Name and target
2923
shell: bash
3024
run: |
@@ -33,9 +27,11 @@ runs:
3327
then
3428
echo "INSTANCE=$PROXYGEN_API_NAME" >> $GITHUB_ENV
3529
echo "TARGET=https://suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
30+
echo "SANDBOX_TAG=latest" >> $GITHUB_ENV
3631
else
3732
echo "TARGET=https://pr$PR_NUMBER.suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
3833
echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
34+
echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
3935
fi
4036
4137
@@ -54,6 +50,12 @@ runs:
5450
envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
5551
envsubst < ./.github/proxygen-settings.yaml | cat
5652
53+
- name: Build internal dev oas
54+
working-directory: .
55+
shell: bash
56+
run: |
57+
make build-json-oas-spec APIM_ENV=dev
58+
5759
- name: Set target
5860
shell: bash
5961
run: |
@@ -65,6 +67,17 @@ runs:
6567
run: |
6668
proxygen instance deploy internal-dev $INSTANCE build/notify-supplier.json --no-confirm
6769
70+
- name: Build sandbox oas
71+
working-directory: .
72+
shell: bash
73+
run: |
74+
make build-json-oas-spec APIM_ENV=sandbox
75+
76+
- name: Set docker tag
77+
shell: bash
78+
run: |
79+
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
80+
6881
- name: Deploy to Internal Dev Sandbox
6982
shell: bash
7083
run: |
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "Build Sandbox"
2+
description: "Build Sandbox"
3+
inputs:
4+
version:
5+
description: "Version number"
6+
required: true
7+
runs:
8+
using: composite
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: 24
16+
17+
- name: Npm install
18+
working-directory: .
19+
run: npm ci
20+
shell: bash
21+
22+
- name: Install Proxygen client
23+
shell: bash
24+
run: |
25+
# Install proxygen cli
26+
pip install pipx
27+
pipx install proxygen-cli
28+
29+
# Setup proxygen auth and settings
30+
mkdir -p ${HOME}/.proxygen
31+
echo -n $PROXYGEN_PRIVATE_KEY | base64 --decode > ${HOME}/.proxygen/key
32+
envsubst < ./.github/proxygen-credentials-template.yaml > ${HOME}/.proxygen/credentials.yaml
33+
envsubst < ./.github/proxygen-credentials-template.yaml | cat
34+
envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
35+
envsubst < ./.github/proxygen-settings.yaml | cat
36+
37+
- name: Setup Sandbox tag
38+
shell: bash
39+
run: |
40+
if [ -z $PR_NUMBER ]
41+
then
42+
echo "SANDBOX_TAG=latest" >> $GITHUB_ENV
43+
else
44+
echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
45+
fi
46+
47+
- name: Build and publish sandbox Docker image
48+
shell: bash
49+
working-directory: ./sandbox
50+
run: |
51+
proxygen docker get-login | bash
52+
docker build -t nhs-notify-supplier:$SANDBOX_TAG .
53+
DOCKER_REGISTRY=$(proxygen docker registry | tail -1)
54+
IMAGE_ID=$(docker images -q nhs-notify-supplier:$SANDBOX_TAG)
55+
docker tag $IMAGE_ID $DOCKER_REGISTRY/nhs-notify-supplier:$SANDBOX_TAG
56+
docker push $DOCKER_REGISTRY/nhs-notify-supplier:$SANDBOX_TAG

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,31 @@ jobs:
9696
PROXYGEN_API_NAME: nhs-notify-supplier
9797
PR_NUMBER: ${{ inputs.pr_number }}
9898
steps:
99-
- name: Verify environment variables
100-
shell: bash
101-
run: |
102-
echo "PROXYGEN_PRIVATE_KEY is set: [${{ secrets.PROXYGEN_ENCODED_NOTIFY_SUPPLIER_PRIVATE_KEY != '' }}]"
103-
echo "PROXYGEN_KID: $PROXYGEN_KID"
104-
echo "PROXYGEN_CLIENT_ID: $PROXYGEN_CLIENT_ID"
105-
echo "PROXYGEN_API_NAME: $PROXYGEN_API_NAME"
106-
echo "PR_NUMBER: $PR_NUMBER"
10799
- name: "Checkout code"
108100
uses: actions/checkout@v4
109101
- name: "Build proxies"
110102
uses: ./.github/actions/build-proxies
111103
with:
112104
version: "${{ inputs.version }}"
113105

106+
artefact-sandbox:
107+
name: "Build sandbox"
108+
runs-on: ubuntu-latest
109+
timeout-minutes: 10
110+
env:
111+
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_ENCODED_NOTIFY_SUPPLIER_PRIVATE_KEY }}
112+
PROXYGEN_KID: notify-supplier-key-1
113+
PROXYGEN_CLIENT_ID: nhs-notify-supplier-client
114+
PROXYGEN_API_NAME: nhs-notify-supplier
115+
PR_NUMBER: ${{ inputs.pr_number }}
116+
steps:
117+
- name: "Checkout code"
118+
uses: actions/checkout@v4
119+
- name: "Build sandbox"
120+
uses: ./.github/actions/build-sandbox
121+
with:
122+
version: "${{ inputs.version }}"
123+
114124
# artefact-1:
115125
# name: "Artefact 1"
116126
# runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ node_modules
2323
dist
2424
.DS_Store
2525
.reports
26+
/sandbox/*.log

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ clean:: # Clean-up project resources (main) @Operations
2626
(cd sdk && make clean)
2727
(cd server && make clean)
2828
(cd src/server && make clean)
29+
30+
guard-%:
31+
@ if [ "${${*}}" = "" ]; then \
32+
echo "Variable $* not set"; \
33+
echo "Usage: make <target> APIM_ENV=<env>"
34+
exit 1; \
35+
fi
2936
serve:
3037
npm run serve
3138

@@ -36,12 +43,40 @@ lint-oas:
3643
publish-oas:
3744
npm run publish-oas
3845

46+
set-target: guard-APIM_ENV
47+
@ TARGET=target-$$APIM_ENV.yml \
48+
envsubst '$${TARGET}' \
49+
< specification/api/components/x-nhsd-apim/target-template.yml > specification/api/components/x-nhsd-apim/target.yml
50+
51+
set-access: guard-APIM_ENV
52+
@ ACCESS=access-$$APIM_ENV.yml \
53+
envsubst '$${ACCESS}' \
54+
< specification/api/components/x-nhsd-apim/access-template.yml > specification/api/components/x-nhsd-apim/access.yml
55+
56+
construct-spec: guard-APIM_ENV
57+
$(MAKE) set-target APIM_ENV=$$APIM_ENV
58+
$(MAKE) set-access APIM_ENV=$$APIM_ENV
59+
60+
build-json-oas-spec: guard-APIM_ENV
61+
$(MAKE) construct-spec APIM_ENV=$$APIM_ENV
62+
$(MAKE) publish-oas
63+
64+
65+
build-yml-oas-spec: guard-APIM_ENV
66+
$(MAKE) construct-spec APIM_ENV=$$APIM_ENV
67+
$(MAKE) bundle-oas
68+
3969
serve-oas:
4070
npm run serve-oas
4171

4272
bundle-oas:
4373
npm run bundle-oas
4474

75+
generate-sandbox:
76+
$(MAKE) build-json-oas-spec APIM_ENV=sandbox
77+
jq --slurpfile status sandbox/HealthcheckEndpoint.json '.paths += $status[0]' build/notify-supplier.json > tmp.json && mv tmp.json build/notify-supplier.json
78+
npm run generate-sandbox
79+
4580
serve-swagger:
4681
npm run serve-swagger-docs
4782

openapitools.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
3+
"generator-cli": {
4+
"version": "7.14.0"
5+
},
6+
"spaces": 2
7+
}

0 commit comments

Comments
 (0)