Skip to content

Commit b29bf3f

Browse files
committed
Fail workflow when the branch already exists.
1 parent 82bc489 commit b29bf3f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

.github/workflows/backport.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,13 @@ jobs:
135135
env:
136136
STEPS_BACKPORT_BRANCH_OUTPUTS_NAME: ${{ steps.backport-branch.outputs.name }}
137137
MATRIX_BRANCH: ${{ matrix.branch }}
138-
run: git checkout -b "${STEPS_BACKPORT_BRANCH_OUTPUTS_NAME}" "origin/${MATRIX_BRANCH}"
138+
run: |
139+
if git ls-remote --exit-code --heads origin "${STEPS_BACKPORT_BRANCH_OUTPUTS_NAME}" > /dev/null 2>&1; then
140+
echo "::error::Branch '${STEPS_BACKPORT_BRANCH_OUTPUTS_NAME}' already exists on origin."
141+
exit 1
142+
fi
143+
144+
git checkout -b "${STEPS_BACKPORT_BRANCH_OUTPUTS_NAME}" "origin/${MATRIX_BRANCH}"
139145
140146
- name: Cherry-pick commit
141147
if: ${{ inputs['commit-sha'] != '' }}

0 commit comments

Comments
 (0)