Skip to content

Commit afa8db3

Browse files
Refactor OAS file, make rules for OAS file and Deploy initial proxy (#80)
* Refactor OAS file, rewrite for phase 1 and make rules for OAS file * Update builds to use generated spec file * initial attempt at git workflow * Post review changes
1 parent 0d5e233 commit afa8db3

File tree

77 files changed

+6938
-5756
lines changed

Some content is hidden

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

77 files changed

+6938
-5756
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,5 @@
9898
"source=${localEnv:HOME}/.gnupg,target=/home/vscode/.gnupg,type=bind,consistency=cached"
9999
],
100100
"name": "Ubuntu",
101-
"postCreateCommand": "pipx install pre-commit && make config && echo 'export GPG_TTY=$TTY' | cat - ~/.zshrc > temp && mv temp ~/.zshrc"
101+
"postCreateCommand": "scripts/devcontainer/postcreatecommand.sh"
102102
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: "Build Proxies"
2+
description: "Build Proxies"
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: Build oas
23+
working-directory: .
24+
shell: bash
25+
run: |
26+
make publish-oas
27+
28+
- name: Setup Proxy Name
29+
shell: bash
30+
run: |
31+
32+
if [ -z $PR_NUMBER ]
33+
then
34+
echo "INSTANCE=$PROXYGEN_API_NAME" >> $GITHUB_ENV
35+
else
36+
echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
37+
fi
38+
39+
40+
- name: Install Proxygen client
41+
shell: bash
42+
run: |
43+
# Install proxygen cli
44+
pip install pipx
45+
pipx install proxygen-cli
46+
47+
# Setup proxygen auth and settings
48+
mkdir -p ${HOME}/.proxygen
49+
echo -n $PROXYGEN_PRIVATE_KEY | base64 --decode > ${HOME}/.proxygen/key
50+
envsubst < ./.github/proxygen-credentials-template.yaml > ${HOME}/.proxygen/credentials.yaml
51+
envsubst < ./.github/proxygen-credentials-template.yaml | cat
52+
envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
53+
envsubst < ./.github/proxygen-settings.yaml | cat
54+
55+
56+
- name: Deploy to Internal Dev
57+
shell: bash
58+
run: |
59+
proxygen instance deploy internal-dev $INSTANCE build/notify-supplier.json --no-confirm
60+
61+
- name: Deploy to Internal Dev Sandbox
62+
shell: bash
63+
run: |
64+
proxygen instance deploy internal-dev-sandbox $INSTANCE build/notify-supplier.json --no-confirm
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
client_id: $PROXYGEN_CLIENT_ID
2+
key_id: $PROXYGEN_KID
3+
private_key_path: key
4+
base_url: https://identity.prod.api.platform.nhs.uk/realms/api-producers

.github/proxygen-settings.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
endpoint_url: https://proxygen.prod.api.platform.nhs.uk
2+
api: nhs-notify-supplier

.github/workflows/cicd-1-pull-request.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
version: ${{ steps.variables.outputs.version }}
2828
is_version_prerelease: ${{ steps.variables.outputs.is_version_prerelease }}
2929
does_pull_request_exist: ${{ steps.pr_exists.outputs.does_pull_request_exist }}
30+
pr_number: ${{ steps.pr_exists.outputs.pr_number }}
3031
steps:
3132
- name: "Checkout code"
3233
uses: actions/checkout@v4
@@ -56,6 +57,8 @@ jobs:
5657
if gh pr list --head $branch_name | grep -q .; then
5758
echo "Pull request exists"
5859
echo "does_pull_request_exist=true" >> $GITHUB_OUTPUT
60+
PR_NUMBER=$(gh pr list --head "$branch_name" --state open --json number -q '.[0].number')
61+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
5962
else
6063
echo "Pull request doesn't exist"
6164
echo "does_pull_request_exist=false" >> $GITHUB_OUTPUT
@@ -72,6 +75,7 @@ jobs:
7275
export VERSION="${{ steps.variables.outputs.version }}"
7376
export DOES_PULL_REQUEST_EXIST="${{ steps.pr_exists.outputs.does_pull_request_exist }}"
7477
export IS_VERSION_PRERELEASE="${{ steps.variables.outputs.is_version_prerelease }}"
78+
export PR_NUMBER="${{ steps.pr_exists.outputs.pr_number }}"
7579
make list-variables
7680
commit-stage: # Recommended maximum execution time is 2 minutes
7781
name: "Commit stage"
@@ -112,6 +116,7 @@ jobs:
112116
python_version: "${{ needs.metadata.outputs.python_version }}"
113117
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
114118
version: "${{ needs.metadata.outputs.version }}"
119+
pr_number: "${{ needs.metadata.outputs.pr_number }}"
115120
secrets: inherit
116121
acceptance-stage: # Recommended maximum execution time is 10 minutes
117122
name: "Acceptance stage"

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ on:
3131
description: "Version of the software, set by the CI/CD pipeline workflow"
3232
required: true
3333
type: string
34+
pr_number:
35+
description: "PR Number if it exists"
36+
required: false
37+
type: string
3438

3539
jobs:
3640
artefact-jekyll-docs:
@@ -81,6 +85,32 @@ jobs:
8185
with:
8286
version: "${{ inputs.version }}"
8387

88+
artefact-proxies:
89+
name: "Build proxies"
90+
runs-on: ubuntu-latest
91+
timeout-minutes: 10
92+
env:
93+
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_ENCODED_NOTIFY_SUPPLIER_PRIVATE_KEY }}
94+
PROXYGEN_KID: notify-supplier-key-1
95+
PROXYGEN_CLIENT_ID: nhs-notify-supplier-client
96+
PROXYGEN_API_NAME: nhs-notify-supplier
97+
PR_NUMBER: ${{ inputs.pr_number }}
98+
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"
107+
- name: "Checkout code"
108+
uses: actions/checkout@v4
109+
- name: "Build proxies"
110+
uses: ./.github/actions/build-proxies
111+
with:
112+
version: "${{ inputs.version }}"
113+
84114
# artefact-1:
85115
# name: "Artefact 1"
86116
# runs-on: ubuntu-latest

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ clean:: # Clean-up project resources (main) @Operations
2929
serve:
3030
npm run serve
3131

32+
33+
lint-oas:
34+
npm run lint-oas
35+
36+
publish-oas:
37+
npm run publish-oas
38+
39+
serve-oas:
40+
npm run serve-oas
41+
42+
bundle-oas:
43+
npm run bundle-oas
44+
3245
serve-swagger:
3346
npm run serve-swagger-docs
3447

0 commit comments

Comments
 (0)