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"
16+ required : true
17+ runId :
18+ description : " GitHub Actions run ID to fetch the OAS artifact from"
619 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,76 +41,76 @@ runs:
1941 run : npm ci
2042 shell : bash
2143
22-
2344 - name : Setup Proxy Name and target
2445 shell : bash
2546 run : |
2647
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+
2759 if [ -z $PR_NUMBER ]
2860 then
2961 echo "INSTANCE=$PROXYGEN_API_NAME" >> $GITHUB_ENV
30- echo "TARGET=https://main.suppliers.dev.nhsnotify.national.nhs.uk " >> $GITHUB_ENV
62+ echo "TARGET=https://main.$TARGET_DOMAIN " >> $GITHUB_ENV
3163 echo "SANDBOX_TAG=latest" >> $GITHUB_ENV
3264 echo "MTLS_NAME=notify-supplier-mtls" >> $GITHUB_ENV
3365 else
34- 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
3567 echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
3668 echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
3769 echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
38-
3970 fi
4071
41-
42- - name : Install Proxygen client
43- shell : bash
44- run : |
45- # Install proxygen cli
46- pip install pipx
47- pipx install proxygen-cli
48-
49- # Setup proxygen auth and settings
50- mkdir -p ${HOME}/.proxygen
51- echo -n $PROXYGEN_PRIVATE_KEY | base64 --decode > ${HOME}/.proxygen/key
52- envsubst < ./.github/proxygen-credentials-template.yaml > ${HOME}/.proxygen/credentials.yaml
53- envsubst < ./.github/proxygen-credentials-template.yaml | cat
54- envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
55- envsubst < ./.github/proxygen-settings.yaml | cat
56-
57-
58- - name : Build internal dev oas
72+ - name : Build ${{ inputs.apimEnv }} oas
5973 working-directory : .
74+ env :
75+ APIM_ENV : ${{ inputs.apimEnv }}
6076 shell : bash
6177 run : |
62- if [ -z $PR_NUMBER ]
78+ if [ ${{ env.APIM_ENV }} == "internal-dev-sandbox" ] && [ ${{ inputs.buildSandbox }} == true ]
6379 then
64- make build-json-oas-spec APIM_ENV=internal-dev
80+ echo "Building sandbox OAS spec"
81+ make build-json-oas-spec APIM_ENV=sandbox
6582 else
66- make build-json-oas-spec APIM_ENV=internal-dev-pr
83+ echo "Building env specific OAS spec"
84+ make build-json-oas-spec APIM_ENV=${{ env.APIM_ENV }}
6785 fi
6886
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-
80- - name : Build sandbox oas
81- working-directory : .
82- shell : bash
83- run : |
84- make build-json-oas-spec APIM_ENV=sandbox
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
8592
86- - name : Set docker tag
87- shell : bash
88- run : |
89- 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
93+ - name : Upload OAS Spec
94+ uses : actions/upload-artifact@v4
95+ with :
96+ name : ${{ env.APIM_ENV }}-build-output
97+ path : ./build
9098
91- - 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 }}
92103 shell : bash
93104 run : |
94- 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