From 3e009f583fc704505dea3e86af5348d11480a7f4 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Wed, 6 Nov 2024 09:56:59 +0900 Subject: [PATCH] PR: troubleshooting the PR not being created --- .github/workflows/pr_from_upstream.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr_from_upstream.yml b/.github/workflows/pr_from_upstream.yml index 118f891..d7d8337 100644 --- a/.github/workflows/pr_from_upstream.yml +++ b/.github/workflows/pr_from_upstream.yml @@ -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()