Skip to content

Commit 7028aa6

Browse files
committed
Conditionally deploy proxy
1 parent 9d84a76 commit 7028aa6

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

.github/workflows/cicd-1-pull-request.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
does_pull_request_exist: ${{ steps.pr_exists.outputs.does_pull_request_exist }}
3030
pr_number: ${{ steps.pr_exists.outputs.pr_number }}
3131
skip_trivy_package: ${{ steps.skip_trivy.outputs.skip_trivy_package }}
32+
deploy_proxy: ${{ steps.deploy_proxy.outputs.deploy_proxy }}
3233
steps:
3334
- name: "Checkout code"
3435
uses: actions/checkout@v5
@@ -87,6 +88,26 @@ jobs:
8788
else
8889
echo "skip_trivy_package=false" >> $GITHUB_OUTPUT
8990
fi
91+
- name: "Determine if proxy should be deployed"
92+
id: deploy_proxy
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
96+
run: |
97+
if [[ -z "$PR_NUMBER" ]]; then
98+
echo "No pull request detected; proxy deployment will run."
99+
echo "deploy_proxy=true" >> $GITHUB_OUTPUT
100+
exit 0
101+
fi
102+
103+
labels=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name')
104+
echo "Labels on PR #$PR_NUMBER: $labels"
105+
106+
if echo "$labels" | grep -Fxq 'deploy-proxy'; then
107+
echo "deploy_proxy=true" >> $GITHUB_OUTPUT
108+
else
109+
echo "deploy_proxy=false" >> $GITHUB_OUTPUT
110+
fi
90111
- name: "List variables"
91112
run: |
92113
export BUILD_DATETIME_LONDON="${{ steps.variables.outputs.build_datetime_london }}"
@@ -141,6 +162,7 @@ jobs:
141162
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
142163
version: "${{ needs.metadata.outputs.version }}"
143164
pr_number: "${{ needs.metadata.outputs.pr_number }}"
165+
deploy_proxy: "${{ needs.metadata.outputs.deploy_proxy }}"
144166
secrets: inherit
145167
acceptance-stage: # Recommended maximum execution time is 10 minutes
146168
name: "Acceptance stage"

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ on:
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

3943
permissions:
4044
id-token: write # This is required for requesting the JWT
@@ -133,7 +137,6 @@ jobs:
133137
pr-create-dynamic-environment:
134138
name: Create Dynamic Environment
135139
runs-on: ubuntu-latest
136-
if: inputs.pr_number != ''
137140
outputs:
138141
environment_name: ${{ steps.set-environment.outputs.environment_name }}
139142
steps:
@@ -162,7 +165,7 @@ jobs:
162165
artefact-proxies:
163166
name: "Build proxies"
164167
runs-on: ubuntu-latest
165-
if: inputs.pr_number != ''
168+
if: inputs.deploy_proxy == 'true'
166169
needs: [artefact-oas-spec-sandbox, pr-create-dynamic-environment]
167170
timeout-minutes: 10
168171
env:

0 commit comments

Comments
 (0)