@@ -4,7 +4,27 @@ description: "Build Proxies"
44inputs :
55 version :
66 description : " Version number"
7+ required : false
8+ releaseVersion :
9+ description : " Release, tag, branch, or commit ID to be used for deployment"
710 required : true
11+ environment :
12+ description : " Deployment environment"
13+ required : true
14+ apimEnv :
15+ description : " APIM environment"
16+ 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'
828
929runs :
1030 using : composite
@@ -25,46 +45,72 @@ runs:
2545 shell : bash
2646 run : |
2747
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
58+
2859 if [ -z $PR_NUMBER ]
2960 then
3061 echo "INSTANCE=$PROXYGEN_API_NAME" >> $GITHUB_ENV
31- echo "TARGET=https://main.suppliers.dev.nhsnotify.national.nhs.uk " >> $GITHUB_ENV
62+ echo "TARGET=https://main.$TARGET_DOMAIN " >> $GITHUB_ENV
3263 echo "SANDBOX_TAG=latest" >> $GITHUB_ENV
3364 echo "MTLS_NAME=notify-supplier-mtls" >> $GITHUB_ENV
3465 else
35- echo "TARGET=https://pr$PR_NUMBER.suppliers.dev.nhsnotify.national.nhs.uk " >> $GITHUB_ENV
66+ echo "TARGET=https://pr$PR_NUMBER.$TARGET_DOMAIN " >> $GITHUB_ENV
3667 echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
3768 echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
3869 echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
3970 fi
4071
41- - name : Install Proxygen client
42- shell : bash
43- run : |
44- # Install proxygen cli
45- pip install pipx
46- pipx install proxygen-cli
47-
48- # Setup proxygen auth and settings
49- mkdir -p ${HOME}/.proxygen
50- echo -n $PROXYGEN_PRIVATE_KEY | base64 --decode > ${HOME}/.proxygen/key
51- envsubst < ./.github/proxygen-credentials-template.yaml > ${HOME}/.proxygen/credentials.yaml
52- envsubst < ./.github/proxygen-credentials-template.yaml | cat
53- envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
54- envsubst < ./.github/proxygen-settings.yaml | cat
55-
56- - name : Build sandbox oas
72+ - name : Build ${{ inputs.apimEnv }} oas
5773 working-directory : .
74+ env :
75+ APIM_ENV : ${{ inputs.apimEnv }}
5876 shell : bash
5977 run : |
60- make build-json-oas-spec APIM_ENV=sandbox
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
6186
62- - name : Set docker tag
63- shell : bash
64- run : |
65- jq --arg newtag "$SANDBOX_TAG" '.["x-nhsd-apim"].target.containers[0].image.tag = $newtag' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
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
92+
93+ - name : Upload OAS Spec
94+ uses : actions/upload-artifact@v4
95+ with :
96+ name : ${{ env.APIM_ENV }}-build-output
97+ path : ./build
6698
67- - 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 }}
68103 shell : bash
69104 run : |
70- 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