Skip to content

Commit 3b7b924

Browse files
authored
CCM-12133: move interal-dev deploy to manual workflow (#155)
* CCM-12133: move interal-dev deploy to manual workflow * CCM-12133: correct build triggers * CCM-12133: version not required * CCM-12133: fix indents * CCM-12133: add tickets to todos * CCM-12133: pr num lookup * CCM-12133: missing envars * CCM-12133: remove on push trigger
1 parent 000ca4c commit 3b7b924

File tree

3 files changed

+111
-28
lines changed

3 files changed

+111
-28
lines changed

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

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: "Build Proxies"
22
description: "Build Proxies"
3+
34
inputs:
45
version:
56
description: "Version number"
67
required: true
8+
79
runs:
810
using: composite
911

@@ -19,7 +21,6 @@ runs:
1921
run: npm ci
2022
shell: bash
2123

22-
2324
- name: Setup Proxy Name and target
2425
shell: bash
2526
run: |
@@ -35,10 +36,8 @@ runs:
3536
echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
3637
echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
3738
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
38-
3939
fi
4040
41-
4241
- name: Install Proxygen client
4342
shell: bash
4443
run: |
@@ -54,29 +53,6 @@ runs:
5453
envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
5554
envsubst < ./.github/proxygen-settings.yaml | cat
5655
57-
58-
- name: Build internal dev oas
59-
working-directory: .
60-
shell: bash
61-
run: |
62-
if [ -z $PR_NUMBER ]
63-
then
64-
make build-json-oas-spec APIM_ENV=internal-dev
65-
else
66-
make build-json-oas-spec APIM_ENV=internal-dev-pr
67-
fi
68-
69-
- name: Set target and cert
70-
shell: bash
71-
run: |
72-
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
73-
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
74-
75-
- name: Deploy to Internal Dev
76-
shell: bash
77-
run: |
78-
proxygen instance deploy internal-dev $INSTANCE build/notify-supplier.json --no-confirm
79-
8056
- name: Build sandbox oas
8157
working-directory: .
8258
shell: bash
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Deploy proxy to internal-dev
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
deploy-internal-dev:
11+
runs-on: ubuntu-latest
12+
name: Deploy to Internal Dev
13+
env:
14+
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_ENCODED_NOTIFY_SUPPLIER_PRIVATE_KEY }}
15+
PROXYGEN_KID: notify-supplier-key-1
16+
PROXYGEN_CLIENT_ID: nhs-notify-supplier-client
17+
PROXYGEN_API_NAME: nhs-notify-supplier
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 24
25+
26+
- name: Npm install
27+
working-directory: .
28+
run: npm ci
29+
shell: bash
30+
31+
- name: "Check if pull request exists for this branch"
32+
id: pr_exists
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
run: |
36+
branch_name=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
37+
echo "Current branch is '$branch_name'"
38+
39+
pr_json=$(gh pr list --head "$branch_name" --state open --json number --limit 1)
40+
pr_number=$(echo "$pr_json" | jq -r '.[0].number // empty')
41+
42+
if [[ -n "$pr_number" ]]; then
43+
echo "Pull request exists: #$pr_number"
44+
echo "does_pull_request_exist=true" >> $GITHUB_OUTPUT
45+
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
46+
else
47+
echo "Pull request doesn't exist"
48+
echo "does_pull_request_exist=false" >> $GITHUB_OUTPUT
49+
echo "pr_number=" >> $GITHUB_OUTPUT
50+
fi
51+
52+
- name: Setup Proxy Name and target
53+
shell: bash
54+
env:
55+
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
56+
run: |
57+
if [ -z $PR_NUMBER ]
58+
then
59+
echo "INSTANCE=$PROXYGEN_API_NAME" >> $GITHUB_ENV
60+
echo "TARGET=https://main.suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
61+
echo "SANDBOX_TAG=latest" >> $GITHUB_ENV
62+
echo "MTLS_NAME=notify-supplier-mtls" >> $GITHUB_ENV
63+
else
64+
echo "TARGET=https://pr$PR_NUMBER.suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
65+
echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
66+
echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
67+
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
68+
fi
69+
70+
- name: Install Proxygen client
71+
shell: bash
72+
run: |
73+
# Install proxygen cli
74+
pip install pipx
75+
pipx install proxygen-cli
76+
77+
# Setup proxygen auth and settings
78+
mkdir -p ${HOME}/.proxygen
79+
echo -n $PROXYGEN_PRIVATE_KEY | base64 --decode > ${HOME}/.proxygen/key
80+
envsubst < ./.github/proxygen-credentials-template.yaml > ${HOME}/.proxygen/credentials.yaml
81+
envsubst < ./.github/proxygen-credentials-template.yaml | cat
82+
envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
83+
envsubst < ./.github/proxygen-settings.yaml | cat
84+
85+
- name: Build internal dev oas
86+
working-directory: .
87+
shell: bash
88+
env:
89+
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
90+
run: |
91+
if [ -z $PR_NUMBER ]
92+
then
93+
make build-json-oas-spec APIM_ENV=internal-dev
94+
else
95+
make build-json-oas-spec APIM_ENV=internal-dev-pr
96+
fi
97+
98+
- name: Set target and cert
99+
shell: bash
100+
run: |
101+
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
102+
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
103+
104+
- name: Deploy to Internal Dev
105+
shell: bash
106+
run: |
107+
proxygen instance deploy internal-dev $INSTANCE build/notify-supplier.json --no-confirm

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ If packages are unavailable the latest SDKs can be downloaded directly from:
6868

6969
### Examples
7070

71-
TODO: Links to example clients.
71+
TODO:CCM-11209 Links to example clients.
7272

7373
## API Developers
7474

@@ -106,7 +106,7 @@ should understand the below.
106106
##### Servers
107107

108108
- Servers folder is being built at build time from OAS specs.
109-
- TODO: Build actual servers
109+
- TODO:CCM-12139 Build actual servers
110110

111111
##### Libs
112112

0 commit comments

Comments
 (0)