Skip to content

Commit bda6bb2

Browse files
committed
afdwf
1 parent 07a8ed2 commit bda6bb2

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

.github/workflows/promote-branch.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ jobs:
132132
133133
echo $pull_request_exists
134134
135-
if [[ $? -eq 0 ]]; then
136-
echo "Base branch ${{ env.base-branch }} does exist."
137-
$pull_request_exists="true"
138-
else
139-
echo "Base branch ${{ env.base-branch }} does not exist."
135+
if [[ $pull_request_exists -eq 0 ]]; then
136+
echo "Pull request does not exist."
140137
$pull_request_exists="false"
138+
else
139+
echo "Pull request does exist."
140+
$pull_request_exists="true"
141141
fi
142142
143143
echo "pull-request-exists=$pull_request_exists" >> $GITHUB_OUTPUT
@@ -153,8 +153,9 @@ jobs:
153153
base-branch: ${{ needs.workflow-variables.outputs.base-branch }}
154154
current-branch: ${{ github.ref_name }}
155155
target-branch: ${{ needs.workflow-variables.outputs.target-branch }}
156+
pull-request-exists: ${{ needs.workflow-variables.outputs.pull-request-exists }}
156157
outputs:
157-
target-branch: ${{ steps.compose-target-branch.outputs.target-branch }}
158+
target-branch: ${{ env.target-branch }}
158159
steps:
159160
- name: 'Checkout ${{ github.head_ref || github.ref }}'
160161
uses: actions/checkout@v5
@@ -175,6 +176,11 @@ jobs:
175176
echo "Default branch is '${{ env.base-branch }}'"
176177
echo "Current branch is '${{ env.current-branch }}'"
177178
exit 1
179+
- name: 'Validate pull request'
180+
if: ${{ env.pull-request-exists == 'true' }}
181+
run: |
182+
echo "Pull request exists."
183+
exit 1
178184
179185
promote-branch:
180186
name: 'Promote branch ${{ github.ref_name }} to ${{ needs.workflow-variables.outputs.target-branch }}'
@@ -196,7 +202,7 @@ jobs:
196202
git switch ${{ needs.workflow-variables.outputs.base-branch }}
197203
git checkout -b ${{ needs.workflow-variables.outputs.target-branch }} origin/${{ needs.workflow-variables.outputs.target-branch }} || git checkout -b ${{ needs.workflow-variables.outputs.target-branch }}
198204
git push --set-upstream origin ${{ needs.workflow-variables.outputs.target-branch }}
199-
- name: 'Create PR'
205+
- name: 'Create PR: "Promote ${{ env.current-branch }} to ${{ env.target-branch }}"'
200206
env:
201207
GH_TOKEN: ${{ github.token }}
202208
current-branch: ${{ github.ref_name }}

0 commit comments

Comments
 (0)