From afac8b0606a5385ed1aa50ccdbc933cfd9490b50 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 5 Nov 2024 22:49:57 +0900 Subject: [PATCH] Fixing PR not being created --- .github/workflows/pr_from_upstream.yml | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr_from_upstream.yml b/.github/workflows/pr_from_upstream.yml index a68b9de..cc7dffe 100644 --- a/.github/workflows/pr_from_upstream.yml +++ b/.github/workflows/pr_from_upstream.yml @@ -44,27 +44,22 @@ jobs: echo "TARGET_BRANCH=${TARGET_BRANCH}" >> $GITHUB_ENV - name: Sync from Upstream Repository + env: + BRANCH_NAME: "sync-${{ github.run_id }}" # Temporary branch name for the PR run: | echo "Syncing from upstream repository $UPSTREAM_REPO on branch $TARGET_BRANCH" # Perform fetch and merge, attempting to resolve conflicts by preferring the upstream changes git fetch "$UPSTREAM_REPO" "$TARGET_BRANCH" - git merge FETCH_HEAD -m "Merge changes from upstream $UPSTREAM_REPO/$TARGET_BRANCH" || { - echo "Conflict detected. Resolving by preferring upstream changes..." - git merge --strategy-option theirs --no-edit FETCH_HEAD - } + git checkout -b "$BRANCH_NAME" - - name: Create a new branch for PR if changes detected - id: create_branch - env: - BRANCH_NAME: "sync-${{ github.run_id }}" # Temporary branch name for the PR - run: | - if [ "$(git status --porcelain)" ]; then - git checkout -b "$BRANCH_NAME" - echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV - else - echo "No changes detected. Exiting." - exit 0 + # Attempt to merge, allowing conflicts + if ! git merge FETCH_HEAD -m "Merge changes from upstream $UPSTREAM_REPO/$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 $UPSTREAM_REPO/$TARGET_BRANCH with conflicts" fi - name: Push changes to new branch