mirror of
https://github.com/RetroDECK/components-template.git
synced 2024-11-21 19:05:39 +00:00
PR: troubleshooting the PR not being created
This commit is contained in:
parent
eab5f80f3b
commit
3e009f583f
16
.github/workflows/pr_from_upstream.yml
vendored
16
.github/workflows/pr_from_upstream.yml
vendored
|
@ -50,24 +50,24 @@ jobs:
|
|||
echo "Syncing from upstream repository ${{ env.UPSTREAM_REPO }} on branch ${{ env.TARGET_BRANCH }}"
|
||||
|
||||
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
|
||||
|
||||
|
||||
# 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
|
||||
git fetch "${{ env.UPSTREAM_REPO }}" "${{ env.TARGET_BRANCH }}"
|
||||
git checkout -b "$BRANCH_NAME"
|
||||
|
||||
|
||||
# Attempt to merge, allowing conflicts
|
||||
if ! git merge FETCH_HEAD -m "Merge changes from upstream ${{ env.UPSTREAM_REPO }}/${{ env.TARGET_BRANCH }}"; then
|
||||
echo "Conflicts detected. Staging conflicted files for the pull request."
|
||||
|
@ -76,17 +76,17 @@ jobs:
|
|||
# Commit the merge with conflicts
|
||||
git commit -m "Merge changes from upstream ${{ env.UPSTREAM_REPO }}/${{ env.TARGET_BRANCH }} with conflicts"
|
||||
fi
|
||||
|
||||
|
||||
# Check if any changes were introduced by the merge
|
||||
if [ -z "$(git diff --stat)" ]; then
|
||||
if git diff --exit-code "origin/${{ env.TARGET_BRANCH }}"; then
|
||||
echo "No changes detected after merging. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
- name: Push changes to new branch
|
||||
if: success()
|
||||
run: |
|
||||
git push origin "${{ env.BRANCH_NAME }}"
|
||||
|
||||
|
||||
- name: Create Pull Request
|
||||
if: success()
|
||||
|
|
Loading…
Reference in a new issue