11name : " Build Proxies"
22description : " Build Proxies"
3+
34inputs :
45 version :
56 description : " Version number"
7+ required : false
8+ releaseVersion :
9+ description : " Release, tag, branch, or commit ID to be used for deployment"
10+ required : true
11+ environment :
12+ description : " Deployment environment"
13+ required : true
14+ apimEnv :
15+ description : " APIM environment"
616 required : true
17+ runId :
18+ description : " GitHub Actions run ID to fetch the OAS artifact from"
19+ required : true
20+ buildSandbox :
21+ description : " Whether to build the sandbox OAS spec"
22+ required : false
23+ default : false
24+ targetComponent :
25+ description : " Name of the Component to deploy"
26+ required : true
27+ default : ' api'
28+
729runs :
830 using : composite
931
@@ -19,46 +41,76 @@ runs:
1941 run : npm ci
2042 shell : bash
2143
22- - name : Build oas
23- working-directory : .
44+ - name : Setup Proxy Name and target
2445 shell : bash
2546 run : |
26- make publish-oas
2747
28- - name : Setup Proxy Name
29- shell : bash
30- run : |
48+ ENV="${{ inputs.apimEnv }}"
49+ if [[ "$ENV" == "internal-dev" || "$ENV" == *pr ]]; then
50+ echo "TARGET_DOMAIN=suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
51+ elif [[ "$ENV" == "int" ]]; then
52+ echo "TARGET_DOMAIN=suppliers.nonprod.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
53+ elif [[ "$ENV" == "prod" ]]; then
54+ echo "TARGET_DOMAIN=suppliers.prod.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
55+ else
56+ echo "TARGET_DOMAIN=suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
57+ fi
3158
3259 if [ -z $PR_NUMBER ]
3360 then
3461 echo "INSTANCE=$PROXYGEN_API_NAME" >> $GITHUB_ENV
62+ echo "TARGET=https://main.$TARGET_DOMAIN" >> $GITHUB_ENV
63+ echo "SANDBOX_TAG=latest" >> $GITHUB_ENV
64+ echo "MTLS_NAME=notify-supplier-mtls" >> $GITHUB_ENV
3565 else
66+ echo "TARGET=https://pr$PR_NUMBER.$TARGET_DOMAIN" >> $GITHUB_ENV
3667 echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
68+ echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
69+ echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
3770 fi
3871
39-
40- - name : Install Proxygen client
72+ - name : Build ${{ inputs.apimEnv }} oas
73+ working-directory : .
74+ env :
75+ APIM_ENV : ${{ inputs.apimEnv }}
4176 shell : bash
4277 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
78+ if [ ${{ env.APIM_ENV }} == "internal-dev-sandbox" ] && [ ${{ inputs.buildSandbox }} == true ]
79+ then
80+ echo "Building sandbox OAS spec"
81+ make build-json-oas-spec APIM_ENV=sandbox
82+ else
83+ echo "Building env specific OAS spec"
84+ make build-json-oas-spec APIM_ENV=${{ env.APIM_ENV }}
85+ fi
5486
87+ if [[ $APIM_ENV == *-pr ]]; then
88+ echo "Removing pr suffix from APIM_ENV after building OAS and calling proxygen"
89+ APIM_ENV=$(echo "$APIM_ENV" | sed 's/-pr$//')
90+ fi
91+ echo "APIM_ENV=$APIM_ENV" >> $GITHUB_ENV
5592
56- - name : Deploy to Internal Dev
57- shell : bash
58- run : |
59- proxygen instance deploy internal-dev $INSTANCE build/notify-supplier.json --no-confirm
93+ - name : Upload OAS Spec
94+ uses : actions/upload-artifact@v4
95+ with :
96+ name : ${{ env.APIM_ENV }}-build-output
97+ path : ./build
6098
61- - name : Deploy to Internal Dev Sandbox
99+ - name : Trigger deploy proxy
100+ env :
101+ APP_CLIENT_ID : ${{ env.APP_CLIENT_ID }}
102+ APP_PEM_FILE : ${{ env.APP_PEM_FILE }}
62103 shell : bash
63104 run : |
64- proxygen instance deploy internal-dev-sandbox $INSTANCE build/notify-supplier.json --no-confirm
105+ .github/scripts/dispatch_internal_repo_workflow.sh \
106+ --infraRepoName "nhs-notify-supplier-api" \
107+ --releaseVersion "${{ inputs.releaseVersion }}" \
108+ --targetComponent "${{ inputs.targetComponent }}" \
109+ --targetWorkflow "proxy-deploy.yaml" \
110+ --targetEnvironment "${{ inputs.environment }}" \
111+ --runId "${{ inputs.runId }}" \
112+ --buildSandbox ${{ inputs.buildSandbox }} \
113+ --apimEnvironment "${{ env.APIM_ENV }}" \
114+ --boundedContext "notify-supplier" \
115+ --targetDomain "$TARGET_DOMAIN" \
116+ --version "${{ inputs.version }}"
0 commit comments