mirror of
https://github.com/RetroDECK/components-template.git
synced 2024-11-24 12:15:38 +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 "Syncing from upstream repository ${{ env.UPSTREAM_REPO }} on branch ${{ env.TARGET_BRANCH }}"
|
||||||
|
|
||||||
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
|
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
|
||||||
|
|
||||||
# Fetch and delete the branch if it exists locally
|
# Fetch and delete the branch if it exists locally
|
||||||
git fetch origin
|
git fetch origin
|
||||||
if git rev-parse --verify "$BRANCH_NAME" >/dev/null 2>&1; then
|
if git rev-parse --verify "$BRANCH_NAME" >/dev/null 2>&1; then
|
||||||
echo "Branch $BRANCH_NAME exists locally. Deleting it."
|
echo "Branch $BRANCH_NAME exists locally. Deleting it."
|
||||||
git branch -D "$BRANCH_NAME"
|
git branch -D "$BRANCH_NAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the branch exists on the remote and delete it if it does
|
# 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
|
if git ls-remote --heads origin "$BRANCH_NAME" | grep "$BRANCH_NAME"; then
|
||||||
echo "Branch $BRANCH_NAME exists on the remote. Deleting it."
|
echo "Branch $BRANCH_NAME exists on the remote. Deleting it."
|
||||||
git push origin --delete "$BRANCH_NAME"
|
git push origin --delete "$BRANCH_NAME"
|
||||||
fi
|
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"
|
||||||
|
|
||||||
# Attempt to merge, allowing conflicts
|
# Attempt to merge, allowing conflicts
|
||||||
if ! git merge FETCH_HEAD -m "Merge changes from upstream ${{ env.UPSTREAM_REPO }}/${{ env.TARGET_BRANCH }}"; then
|
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."
|
echo "Conflicts detected. Staging conflicted files for the pull request."
|
||||||
|
@ -76,17 +76,17 @@ jobs:
|
||||||
# Commit the merge with conflicts
|
# Commit the merge with conflicts
|
||||||
git commit -m "Merge changes from upstream ${{ env.UPSTREAM_REPO }}/${{ env.TARGET_BRANCH }} with conflicts"
|
git commit -m "Merge changes from upstream ${{ env.UPSTREAM_REPO }}/${{ env.TARGET_BRANCH }} with conflicts"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if any changes were introduced by the merge
|
# 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."
|
echo "No changes detected after merging. Exiting."
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Push changes to new branch
|
- name: Push changes to new branch
|
||||||
if: success()
|
if: success()
|
||||||
run: |
|
run: |
|
||||||
git push origin "${{ env.BRANCH_NAME }}"
|
git push origin "${{ env.BRANCH_NAME }}"
|
||||||
|
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
if: success()
|
if: success()
|
||||||
|
|
Loading…
Reference in a new issue