diff --git a/.github/workflows/release-to-dev.yaml b/.github/workflows/release-to-dev.yaml index 1181697..576f4f1 100644 --- a/.github/workflows/release-to-dev.yaml +++ b/.github/workflows/release-to-dev.yaml @@ -33,20 +33,29 @@ jobs: - name: Attempt to merge each commit individually run: | - FAILED=false for COMMIT_HASH in ${{ steps.commits.outputs.commits_list }} do - git cherry-pick $COMMIT_HASH || FAILED=true - if [ "$FAILED" = true ]; then - git cherry-pick --abort - echo "Conflicts detected for commit $COMMIT_HASH. Creating a pull request." - BRANCH_NAME="conflict-${COMMIT_HASH}" - git checkout -b $BRANCH_NAME - git cherry-pick $COMMIT_HASH - git push origin $BRANCH_NAME - gh pr create --base development --head $BRANCH_NAME --title "Resolve Conflict for Commit $COMMIT_HASH" --body "This PR is created to resolve conflicts for commit $COMMIT_HASH." - git checkout development - FAILED=false + git cherry-pick $COMMIT_HASH + if [ $? -ne 0 ]; then # Check if cherry-pick failed + if git diff --cached --exit-code; then # Check if there are changes to commit + echo "Cherry-pick resulted in no changes, skipping..." + git cherry-pick --skip + else + echo "Conflicts detected for commit $COMMIT_HASH, creating a pull request." + git cherry-pick --abort + BRANCH_NAME="conflict-${COMMIT_HASH}" + git checkout -b $BRANCH_NAME + git cherry-pick $COMMIT_HASH + # Handle if cherry-pick is still problematic + if git diff --cached --exit-code; then + git commit --allow-empty -m "Handle empty cherry-pick for commit $COMMIT_HASH" + else + git commit -m "Apply changes for commit $COMMIT_HASH" + fi + git push origin $BRANCH_NAME + gh pr create --base development --head $BRANCH_NAME --title "Resolve Conflict for Commit $COMMIT_HASH" --body "This PR is created to resolve conflicts for commit $COMMIT_HASH." + git checkout development + fi else git push origin development fi