Skip to content

Commit 7288d93

Browse files
authored
ELI-338: Adding workflow setup for dev, sandbox, preprod and prod (#314)
* ELI-338: Tests sandbox * ELI-338: Adds explicit python and poetry install * ELI-338: Adds collection id for postman * ELI-338: Adds json under collection key * ELI-338: Adds json properly using jq * ELI-338: Adds checkout step for tagging * ELI-338: Adds dependency for version in tagging * ELI-338: fix targets and access * ELI-338: try with dev instead of internal-dev * ELI-338: setting ref to internal dev * ELI-338: setting ref to internal dev for x-nhsd-apim * ELI-338: fixes url in target * ELI-338: fixes setup for preprod and prod
1 parent f856ffe commit 7288d93

12 files changed

Lines changed: 129 additions & 32 deletions

.github/workflows/dev_sandbox_publish_deploy.yaml

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jobs:
2323
echo "Deploying to: DEV & Sandbox"
2424
echo "VERSION=${{ steps.variables.outputs.version }}"
2525
26-
dev:
26+
internal-dev:
27+
name: "Publish spec & deploy to dev"
2728
needs: metadata
2829
runs-on: ubuntu-latest
2930
steps:
@@ -71,7 +72,8 @@ jobs:
7172
proxygen instance deploy internal-dev eligibility-signposting-api build/specification/internal-dev/eligibility-signposting-api.yaml --no-confirm
7273
7374
sandbox:
74-
needs: dev
75+
name: "Publish spec & deploy to sandbox"
76+
needs: internal-dev
7577
runs-on: ubuntu-latest
7678
steps:
7779
- name: Checkout repository
@@ -118,28 +120,49 @@ jobs:
118120
proxygen instance deploy sandbox eligibility-signposting-api build/specification/sandbox/eligibility-signposting-api.yaml --no-confirm
119121
120122
publish_postman:
123+
name: "Publish to Postman"
121124
needs: sandbox
122125
runs-on: ubuntu-latest
123126
steps:
124-
- uses: actions/checkout@v6
125-
- name: Install dependencies
126-
run: make install
127+
- name: Checkout repository
128+
uses: actions/checkout@v6
129+
130+
- name: Set up Python 3.11
131+
uses: actions/setup-python@v6
132+
with:
133+
python-version: '3.11'
134+
135+
- name: Set up Node.js
136+
uses: actions/setup-node@v6
137+
with:
138+
node-version: '20'
139+
140+
- name: Install Poetry
141+
run: curl -sSL https://install.python-poetry.org | python3 -
142+
143+
- name: Install Python and Node dependencies
144+
run: |
145+
make install
127146
- name: Generate Postman Collection
128147
run: make convert-postman
129148
- name: Publish Postman Collection
130149
env:
131150
POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}
132151
run: |
133-
curl --fail -X PUT \
134-
https://api.getpostman.com/collections/{{YOUR_COLLECTION_UID}} \
152+
jq -c '{collection: .}' specification/postman/collection.json > wrapped_collection.json
153+
curl -X PUT \
154+
https://api.getpostman.com/collections/44595835-573a42db-b7a5-4b69-9f62-696b6df3f12f \
135155
-H "X-Api-Key: $POSTMAN_API_KEY" \
136156
-H "Content-Type: application/json" \
137-
-d @specification/postman/collection.json
157+
-d @wrapped_collection.json
138158
139-
publish:
140-
needs: publish_postman
159+
tag_deployment:
160+
name: "Tag Dev & Sandbox deployment"
161+
needs: [metadata, publish_postman]
141162
runs-on: ubuntu-latest
142163
steps:
164+
- name: Checkout repository
165+
uses: actions/checkout@v6
143166
- name: "Tag the dev & sandbox deployment"
144167
run: |
145168
git config user.name "github-actions"
@@ -148,7 +171,8 @@ jobs:
148171
git push origin ${{ needs.metadata.outputs.version }}
149172
150173
notify_slack:
151-
needs: publish
174+
name: "Notify Slack"
175+
needs: tag_deployment
152176
runs-on: ubuntu-latest
153177
steps:
154178
- name: "Notify Slack on PR merge"

.github/workflows/preprod_publish_deploy.yaml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
preprod:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v6
1615
- name: Set tag to deploy
1716
id: set_tag
1817
run: |
@@ -27,13 +26,35 @@ jobs:
2726
uses: actions/checkout@v6
2827
with:
2928
ref: ${{ steps.set_tag.outputs.tag }}
30-
- uses: actions/setup-python@v6
29+
- name: Set up Python 3.11
30+
uses: actions/setup-python@v6
3131
with:
3232
python-version: '3.11'
33-
- uses: actions/setup-node@v6
33+
- name: Set up Node.js
34+
uses: actions/setup-node@v6
3435
with:
3536
node-version: '20'
36-
- run: make install
37-
- run: make construct-spec APIM_ENV=preprod
38-
- run: make publish-spec APIM_ENV=preprod
39-
- run: make deploy-spec APIM_ENV=preprod
37+
- name: Install Poetry
38+
run: curl -sSL https://install.python-poetry.org | python3 -
39+
- name: Install Python and Node dependencies
40+
run: |
41+
make install
42+
- name: Install proxygen-cli
43+
run: |
44+
pip install proxygen-cli
45+
- name: Set up Proxygen credentials
46+
env:
47+
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }}
48+
run: |
49+
mkdir -p ~/.proxygen
50+
echo "$PROXYGEN_PRIVATE_KEY" > ~/.proxygen/eligibility-signposting-api.pem
51+
make setup-proxygen-credentials
52+
- name: Generate specification
53+
run: |
54+
make construct-spec APIM_ENV=preprod
55+
- name: Publish preprod spec to Proxygen
56+
run: |
57+
proxygen spec publish build/specification/preprod/eligibility-signposting-api.yaml --uat --no-confirm
58+
- name: Deploy preprod spec to Proxygen
59+
run: |
60+
proxygen instance deploy preprod eligibility-signposting-api build/specification/preprod/eligibility-signposting-api.yaml --no-confirm

.github/workflows/prod_publish_deploy.yaml

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,52 @@ jobs:
1111
prod:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v6
14+
- name: Set tag to deploy
15+
id: set_tag
16+
run: |
17+
if [ "${{ github.event.inputs.ref }}" = "latest" ]; then
18+
TAG=$(git tag --list 'spec-*' --sort=-v:refname | head -n 1)
19+
echo "Using latest tag: $TAG"
20+
echo "tag=$TAG" >> $GITHUB_OUTPUT
21+
else
22+
echo "tag=${{ github.event.inputs.ref }}" >> $GITHUB_OUTPUT
23+
fi
1524
- name: Checkout tag
1625
uses: actions/checkout@v6
1726
with:
18-
ref: ${{ inputs.ref }}
19-
- uses: actions/setup-python@v6
27+
ref: ${{ steps.set_tag.outputs.tag }}
28+
- name: Set up Python 3.11
29+
uses: actions/setup-python@v6
2030
with:
2131
python-version: '3.11'
22-
- uses: actions/setup-node@v6
32+
- name: Set up Node.js
33+
uses: actions/setup-node@v6
2334
with:
2435
node-version: '20'
25-
- run: make install
26-
- run: make construct-spec APIM_ENV=prod
27-
- run: make publish-spec APIM_ENV=prod
28-
- run: make deploy-spec APIM_ENV=prod
36+
- name: Install Poetry
37+
run: curl -sSL https://install.python-poetry.org | python3 -
38+
- name: Install Python and Node dependencies
39+
run: |
40+
make install
41+
- name: Install proxygen-cli
42+
run: |
43+
pip install proxygen-cli
44+
- name: Set up Proxygen credentials
45+
env:
46+
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }}
47+
run: |
48+
mkdir -p ~/.proxygen
49+
echo "$PROXYGEN_PRIVATE_KEY" > ~/.proxygen/eligibility-signposting-api.pem
50+
make setup-proxygen-credentials
51+
- name: Generate specification
52+
run: |
53+
make construct-spec APIM_ENV=prod
54+
- name: Publish prod spec to Proxygen
55+
run: |
56+
proxygen spec publish build/specification/prod/eligibility-signposting-api.yaml --no-confirm
57+
- name: Deploy prod spec to Proxygen
58+
run: |
59+
proxygen instance deploy prod eligibility-signposting-api build/specification/prod/eligibility-signposting-api.yaml --no-confirm
2960
3061
create_release:
3162
needs: prod
@@ -38,5 +69,7 @@ jobs:
3869
with:
3970
tag_name: ${{ inputs.ref }}
4071
release_name: Release ${{ inputs.ref }}
72+
body: |
73+
Auto-release created during production deployment.
4174
draft: false
4275
prerelease: false

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ set-ratelimit: guard-APIM_ENV
114114
< specification/x-nhsd-apim/ratelimit-template.yaml > specification/x-nhsd-apim/ratelimit.yaml
115115

116116
update-spec-template: guard-APIM_ENV
117-
ifeq ($(APIM_ENV), $(filter $(APIM_ENV), sandbox internal-dev test int ref preprod prod ))
117+
ifeq ($(APIM_ENV), $(filter $(APIM_ENV), sandbox internal-dev test int ref preprod prod dev))
118118
@ $(MAKE) set-target APIM_ENV=$$APIM_ENV
119119
@ $(MAKE) set-access APIM_ENV=$$APIM_ENV
120120
@ $(MAKE) set-security APIM_ENV=$$APIM_ENV
121121
@ $(MAKE) set-ratelimit APIM_ENV=$$APIM_ENV
122122
else
123-
@ echo ERROR: $$APIM_ENV is not a valid environment. Please use one of [sandbox, internal-dev, int, ref, preprod, prod]
123+
@ echo ERROR: $$APIM_ENV is not a valid environment. Please use one of [sandbox, internal-dev, test, int, ref, preprod, prod, dev]
124124
@ exit 1;
125125
endif
126126

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
nhs-login-p9:
2+
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/nhs-login-p9
3+
app-level3:
4+
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/app-level3
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- title: Eligibility Signposting API (Dev Environment)
2+
grants:
3+
nhs-login-p9: []
4+
- title: Eligibility Signposting API (Dev Environment) app Level 3 Access
5+
grants:
6+
app-level3: []
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
proxy:
2+
limit: 5
3+
timeunit: second

specification/x-nhsd-apim/target-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
type: external
2-
url: "TBC"
2+
url: "https://dev.eligibility-signposting-api.nhs.uk"
33
healthcheck: /patient-check/_status
44
security:
55
type: mtls
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type: external
2+
url: "https://internal-dev.eligibility-signposting-api.nhs.uk"
3+
healthcheck: /patient-check/_status
4+
security:
5+
type: mtls
6+
secret: eligibility-signposting-api

specification/x-nhsd-apim/target-preprod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
type: external
2-
url: "preprod.eligibility-signposting-api.nhs.uk"
2+
url: "https://preprod.eligibility-signposting-api.nhs.uk"
33
healthcheck: /patient-check/_status
44
security:
55
type: mtls

0 commit comments

Comments
 (0)