Fixing PR not being created

This commit is contained in:
XargonWan 2024-11-05 22:49:57 +09:00
parent 437b595042
commit afac8b0606

View file

@ -44,27 +44,22 @@ jobs:
echo "TARGET_BRANCH=${TARGET_BRANCH}" >> $GITHUB_ENV echo "TARGET_BRANCH=${TARGET_BRANCH}" >> $GITHUB_ENV
- name: Sync from Upstream Repository - name: Sync from Upstream Repository
env:
BRANCH_NAME: "sync-${{ github.run_id }}" # Temporary branch name for the PR
run: | run: |
echo "Syncing from upstream repository $UPSTREAM_REPO on branch $TARGET_BRANCH" echo "Syncing from upstream repository $UPSTREAM_REPO on branch $TARGET_BRANCH"
# 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 "$UPSTREAM_REPO" "$TARGET_BRANCH" git fetch "$UPSTREAM_REPO" "$TARGET_BRANCH"
git merge FETCH_HEAD -m "Merge changes from upstream $UPSTREAM_REPO/$TARGET_BRANCH" || { git checkout -b "$BRANCH_NAME"
echo "Conflict detected. Resolving by preferring upstream changes..."
git merge --strategy-option theirs --no-edit FETCH_HEAD
}
- name: Create a new branch for PR if changes detected # Attempt to merge, allowing conflicts
id: create_branch if ! git merge FETCH_HEAD -m "Merge changes from upstream $UPSTREAM_REPO/$TARGET_BRANCH"; then
env: echo "Conflicts detected. Staging conflicted files for the pull request."
BRANCH_NAME: "sync-${{ github.run_id }}" # Temporary branch name for the PR # Stage all changes, including conflicts
run: | git add -A
if [ "$(git status --porcelain)" ]; then # Commit the merge with conflicts
git checkout -b "$BRANCH_NAME" git commit -m "Merge changes from upstream $UPSTREAM_REPO/$TARGET_BRANCH with conflicts"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
else
echo "No changes detected. Exiting."
exit 0
fi fi
- name: Push changes to new branch - name: Push changes to new branch