mirror of
https://github.com/RetroDECK/components-template.git
synced 2024-11-25 04:35:38 +00:00
PR: deleting branch if already existing
This commit is contained in:
parent
4f2e2c485d
commit
d17fa582a8
13
.github/workflows/pr_from_upstream.yml
vendored
13
.github/workflows/pr_from_upstream.yml
vendored
|
@ -49,6 +49,19 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
echo "Syncing from upstream repository ${{ env.UPSTREAM_REPO }} on branch ${{ env.TARGET_BRANCH }}"
|
echo "Syncing from upstream repository ${{ env.UPSTREAM_REPO }} on branch ${{ env.TARGET_BRANCH }}"
|
||||||
|
|
||||||
|
# Fetch and delete the branch if it exists locally
|
||||||
|
git fetch origin
|
||||||
|
if git rev-parse --verify "$BRANCH_NAME" >/dev/null 2>&1; then
|
||||||
|
echo "Branch $BRANCH_NAME exists locally. Deleting it."
|
||||||
|
git branch -D "$BRANCH_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the branch exists on the remote and delete it if it does
|
||||||
|
if git ls-remote --heads origin "$BRANCH_NAME" | grep "$BRANCH_NAME"; then
|
||||||
|
echo "Branch $BRANCH_NAME exists on the remote. Deleting it."
|
||||||
|
git push origin --delete "$BRANCH_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
# Perform fetch and merge, attempting to resolve conflicts by preferring the upstream changes
|
# Perform fetch and merge, attempting to resolve conflicts by preferring the upstream changes
|
||||||
git fetch "${{ env.UPSTREAM_REPO }}" "${{ env.TARGET_BRANCH }}"
|
git fetch "${{ env.UPSTREAM_REPO }}" "${{ env.TARGET_BRANCH }}"
|
||||||
git checkout -b "$BRANCH_NAME"
|
git checkout -b "$BRANCH_NAME"
|
||||||
|
|
Loading…
Reference in a new issue