3535 description : " PR Number if it exists"
3636 required : false
3737 type : string
38+ deploy_proxy :
39+ description : " True if the APIM proxy should be deployed"
40+ required : true
41+ type : string
3842
3943permissions :
4044 id-token : write # This is required for requesting the JWT
@@ -133,9 +137,13 @@ jobs:
133137 pr-create-dynamic-environment :
134138 name : Create Dynamic Environment
135139 runs-on : ubuntu-latest
136- if : inputs.pr_number != ''
140+ outputs :
141+ environment_name : ${{ steps.set-environment.outputs.environment_name }}
137142 steps :
138143 - uses : actions/checkout@v5
144+ - name : Set environment name
145+ id : set-environment
146+ run : echo "environment_name=${{ inputs.pr_number != '' && format('pr{0}', inputs.pr_number) || 'main' }}" >> $GITHUB_OUTPUT
139147 - name : Trigger dynamic environment creation
140148 env :
141149 APP_CLIENT_ID : ${{ secrets.APP_CLIENT_ID }}
@@ -148,7 +156,7 @@ jobs:
148156 --infraRepoName "$(echo ${{ github.repository }} | cut -d'/' -f2)" \
149157 --releaseVersion ${{ github.head_ref || github.ref_name }} \
150158 --targetWorkflow "dispatch-deploy-dynamic-env.yaml" \
151- --targetEnvironment "pr${PR_NUMBER }" \
159+ --targetEnvironment "${{ steps.set-environment.outputs.environment_name } }" \
152160 --targetComponent "api" \
153161 --targetAccountGroup "nhs-notify-supplier-api-dev" \
154162 --terraformAction "apply" \
@@ -157,12 +165,11 @@ jobs:
157165 artefact-proxies :
158166 name : " Build proxies"
159167 runs-on : ubuntu-latest
160- if : inputs.pr_number != ' '
168+ if : inputs.deploy_proxy == 'true '
161169 needs : [artefact-oas-spec-sandbox, pr-create-dynamic-environment]
162170 timeout-minutes : 10
163171 env :
164172 PROXYGEN_API_NAME : nhs-notify-supplier
165- PR_NUMBER : ${{ inputs.pr_number }}
166173 APP_CLIENT_ID : ${{ secrets.APP_CLIENT_ID }}
167174 APP_PEM_FILE : ${{ secrets.APP_PEM_FILE }}
168175 steps :
@@ -172,7 +179,7 @@ jobs:
172179 uses : ./.github/actions/build-proxies
173180 with :
174181 version : " ${{ inputs.version }}"
175- environment : ${{ inputs.pr_number != '' && format('pr{0}', inputs.pr_number) || 'main' }}
182+ environment : ${{ needs.pr-create-dynamic-environment.outputs.environment_name }}
176183 apimEnv : " internal-dev-sandbox"
177184 runId : " ${{ github.run_id }}"
178185 buildSandbox : true
0 commit comments