Skip to content

Commit 9d84a76

Browse files
committed
Refactor environment calculation
1 parent c7a8a06 commit 9d84a76

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

.github/workflows/stage-3-build.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,13 @@ jobs:
134134
name: Create Dynamic Environment
135135
runs-on: ubuntu-latest
136136
if: inputs.pr_number != ''
137+
outputs:
138+
environment_name: ${{ steps.set-environment.outputs.environment_name }}
137139
steps:
138140
- uses: actions/checkout@v5
141+
- name: Set environment name
142+
id: set-environment
143+
run: echo "environment_name=${{ inputs.pr_number != '' && format('pr{0}', inputs.pr_number) || 'main' }}" >> $GITHUB_OUTPUT
139144
- name: Trigger dynamic environment creation
140145
env:
141146
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
@@ -148,7 +153,7 @@ jobs:
148153
--infraRepoName "$(echo ${{ github.repository }} | cut -d'/' -f2)" \
149154
--releaseVersion ${{ github.head_ref || github.ref_name }} \
150155
--targetWorkflow "dispatch-deploy-dynamic-env.yaml" \
151-
--targetEnvironment "pr${PR_NUMBER}" \
156+
--targetEnvironment "${{ steps.set-environment.outputs.environment_name }}" \
152157
--targetComponent "api" \
153158
--targetAccountGroup "nhs-notify-supplier-api-dev" \
154159
--terraformAction "apply" \
@@ -162,7 +167,6 @@ jobs:
162167
timeout-minutes: 10
163168
env:
164169
PROXYGEN_API_NAME: nhs-notify-supplier
165-
PR_NUMBER: ${{ inputs.pr_number }}
166170
APP_CLIENT_ID: ${{ secrets.APP_CLIENT_ID }}
167171
APP_PEM_FILE: ${{ secrets.APP_PEM_FILE }}
168172
steps:
@@ -172,7 +176,7 @@ jobs:
172176
uses: ./.github/actions/build-proxies
173177
with:
174178
version: "${{ inputs.version }}"
175-
environment: ${{ inputs.pr_number != '' && format('pr{0}', inputs.pr_number) || 'main' }}
179+
environment: ${{ needs.pr-create-dynamic-environment.outputs.environment_name }}
176180
apimEnv: "internal-dev-sandbox"
177181
runId: "${{ github.run_id }}"
178182
buildSandbox: true

0 commit comments

Comments
 (0)