diff --git a/.github/workflows/pr_from_upstream.yml b/.github/workflows/pr_from_upstream.yml index d7d8337..ae78d1b 100644 --- a/.github/workflows/pr_from_upstream.yml +++ b/.github/workflows/pr_from_upstream.yml @@ -64,29 +64,22 @@ jobs: git push origin --delete "$BRANCH_NAME" fi - # Perform fetch and merge, attempting to resolve conflicts by preferring the upstream changes + # Fetch changes from the upstream repository without merging git fetch "${{ env.UPSTREAM_REPO }}" "${{ env.TARGET_BRANCH }}" + + # Create a new branch and apply the upstream changes git checkout -b "$BRANCH_NAME" + git reset --hard FETCH_HEAD - # 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." - # Stage all changes, including conflicts - git add -A - # 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 git diff --exit-code "origin/${{ env.TARGET_BRANCH }}"; then - echo "No changes detected after merging. Exiting." + # Check if there are any changes to commit + if git diff --exit-code origin/${{ env.TARGET_BRANCH }}; then + echo "No changes detected from upstream. Exiting without creating PR." fi - name: Push changes to new branch if: success() run: | git push origin "${{ env.BRANCH_NAME }}" - - name: Create Pull Request if: success()