Skip to content

Commit 244d4bc

Browse files
initial attempt at git workflow
1 parent 69ca889 commit 244d4bc

File tree

11 files changed

+113
-22
lines changed

11 files changed

+113
-22
lines changed
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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"scripts": {
4848
"build": "npm run bundle-oas && npm run generate --buildver=$npm_config_buildver",
49-
"bundle-oas": "mkdir -p build && redocly bundle specification/api/notify-supplier-phase1.yml --dereferenced --remove-unused-components --ext yml > build/notify-supplier.yml",
49+
"bundle-oas": "mkdir -p build && redocly bundle specification/api/notify-supplier-phase1.yml --dereferenced -k --remove-unused-components --ext yml > build/notify-supplier.yml",
5050
"generate": "npm run generate:cs --buildver=$npm_config_buildver && npm run generate:html && npm run generate:ts --buildver=$npm_config_buildver && npm run generate:python",
5151
"generate-dependencies": "npm run generate-dependencies --workspaces --if-present",
5252
"generate:cs": "./sdk/generate-cs.sh $npm_config_buildver",
@@ -57,7 +57,7 @@
5757
"lint": "npm run lint --workspaces",
5858
"lint-oas": "redocly lint specification/api/notify-supplier-phase1.yml",
5959
"lint:fix": "npm run lint:fix --workspaces",
60-
"publish-oas": "mkdir -p build && redocly bundle specification/api/notify-supplier-phase1.yml --dereferenced --remove-unused-components --ext json > build/notify-supplier.json",
60+
"publish-oas": "mkdir -p build && redocly bundle specification/api/notify-supplier-phase1.yml --dereferenced -k --remove-unused-components --ext json > build/notify-supplier.json",
6161
"serve": "npm run serve-html-docs",
6262
"serve-html-docs": "npx serve sdk/html -p 3050",
6363
"serve-oas": "redocly preview-docs -p 5000 build/notify-supplier.json",

specification/api/components/endpoints/getDataId.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ summary: Fetch a data file
22
operationId: get-data-id
33
tags:
44
- data
5-
x-stoplight:
6-
id: 98lwlebl1vxeq
75
responses:
86
"303":
97
description: See Other

specification/api/components/schemas/LetterStatusItem.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ properties:
1717
$ref: "./LetterStatus.yml"
1818
requestedProductionStatus:
1919
$ref: "./ProductionStatus.yml"
20-
x-stoplight:
21-
id: kqs13rn7s4wv3
2220
reasonCode:
2321
type: number
2422
description: Reason code for the given status

specification/api/components/schemas/LetterUpdateItem.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ properties:
1414
$ref: "./LetterStatus.yml"
1515
requestedProductionStatus:
1616
$ref: "./ProductionStatus.yml"
17-
x-stoplight:
18-
id: tqw1mlpdzl3v7
1917
description: |-
2018
The requested production status for this letter.
2119
May only be set by NHS Notify.

specification/api/components/schemas/ProductionStatus.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
type: string
2-
x-stoplight:
3-
id: lvub504h38th0
42
enum:
53
- ACTIVE
64
- HOLD

0 commit comments

Comments
 (0)