Skip to content

Commit 0a08678

Browse files
committed
CCM-12133: pr num lookup
1 parent fa4533c commit 0a08678

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

.github/actions/build-proxies/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ runs:
3636
echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
3737
echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
3838
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
39-
4039
fi
4140
4241
- name: Install Proxygen client

.github/workflows/manual-proxy-internal-dev-deploy.yaml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Deploy proxy to internal-dev
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
pr_number:
7-
description: "PR Number for PR Environment"
8-
required: false
5+
push:
6+
branches:
7+
- "**"
8+
- '!master'
99

1010
permissions:
1111
contents: read
@@ -17,7 +17,6 @@ jobs:
1717
env:
1818
PROXYGEN_API_NAME: notify-supplier-api
1919
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_PRIVATE_KEY }}
20-
PR_NUMBER: ${{ github.event.inputs.pr_number }}
2120
steps:
2221
- name: Checkout
2322
uses: actions/checkout@v4
@@ -31,8 +30,31 @@ jobs:
3130
run: npm ci
3231
shell: bash
3332

33+
- name: "Check if pull request exists for this branch"
34+
id: pr_exists
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
branch_name=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
39+
echo "Current branch is '$branch_name'"
40+
41+
pr_json=$(gh pr list --head "$branch_name" --state open --json number --limit 1)
42+
pr_number=$(echo "$pr_json" | jq -r '.[0].number // empty')
43+
44+
if [[ -n "$pr_number" ]]; then
45+
echo "Pull request exists: #$pr_number"
46+
echo "does_pull_request_exist=true" >> $GITHUB_OUTPUT
47+
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
48+
else
49+
echo "Pull request doesn't exist"
50+
echo "does_pull_request_exist=false" >> $GITHUB_OUTPUT
51+
echo "pr_number=" >> $GITHUB_OUTPUT
52+
fi
53+
3454
- name: Setup Proxy Name and target
3555
shell: bash
56+
env:
57+
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
3658
run: |
3759
if [ -z $PR_NUMBER ]
3860
then
@@ -65,6 +87,8 @@ jobs:
6587
- name: Build internal dev oas
6688
working-directory: .
6789
shell: bash
90+
env:
91+
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
6892
run: |
6993
if [ -z $PR_NUMBER ]
7094
then

0 commit comments

Comments
 (0)