Skip to content

Commit 5c14cfd

Browse files
committed
safw
1 parent 0f04f5b commit 5c14cfd

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

.github/workflows/promote-branch.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
base-branch: ${{ steps.set-base-branch.outputs.base-branch }}
5858
target-branch: ${{ steps.set-target-branch.outputs.target-branch }}
5959
target-branch-exists: ${{ steps.check-target-branch-exists.outputs.target-branch-exists }}
60+
pull-request-exists: ${{ steps.check-pull-request-exists.outputs.pull-request-exists }}
6061
steps:
6162
- name: 'Set target branch'
6263
id: set-target-branch
@@ -111,12 +112,34 @@ jobs:
111112
echo "Base branch ${{ env.base-branch }} does exist."
112113
base_branch_exists="true"
113114
else
114-
echo "TarBaseget branch ${{ env.base-branch }} does not exist."
115+
echo "Base branch ${{ env.base-branch }} does not exist."
115116
base_branch_exists="false"
116117
fi
117118
118119
echo "base-branch-exists=$base_branch_exists" >> $GITHUB_OUTPUT
119120
121+
set -e
122+
- name: 'Check if pull request exists exists'
123+
id: check-pull-request-exists
124+
env:
125+
GH_TOKEN: ${{ github.token }}
126+
current-branch: ${{ github.ref_name }}
127+
target-branch: ${{ needs.workflow-variables.outputs.target-branch }}
128+
run: |
129+
set +e
130+
131+
pull_request_exists=$(echo gh pr list --head ${{ env.current-branch }} -base ${{ env.target-branch }} --state "open" --limit 1 --jq '.total_count')
132+
133+
if [[ $? -eq 0 ]]; then
134+
echo "Base branch ${{ env.base-branch }} does exist."
135+
$pull_request_exists="true"
136+
else
137+
echo "Base branch ${{ env.base-branch }} does not exist."
138+
$pull_request_exists="false"
139+
fi
140+
141+
echo "pull-request-exists=$pull_request_exists" >> $GITHUB_OUTPUT
142+
120143
set -e
121144
122145
validate-promotion:

0 commit comments

Comments
 (0)