diff --git a/.github/workflows/cherry-pick.yml b/.github/workflows/cherry-pick.yml index c6e1bad992e..656d03af6db 100644 --- a/.github/workflows/cherry-pick.yml +++ b/.github/workflows/cherry-pick.yml @@ -106,16 +106,13 @@ jobs: git fetch origin "$TARGET_BRANCH" git checkout -b "$NEW_BRANCH" "origin/$TARGET_BRANCH" - # Cherry pick - # Try standard cherry-pick first (for squash merges or single commits) - if git cherry-pick "$MERGE_COMMIT_SHA"; then - echo "Cherry-pick successful." + # Cherry pick without committing to control commit message + if git cherry-pick --no-commit "$MERGE_COMMIT_SHA"; then + echo "Cherry-pick applied (no commit)." else - echo "Standard cherry-pick failed, trying with -m 1 (for merge commits)..." + echo "Standard cherry-pick failed, trying with -m 1..." git cherry-pick --abort - if git cherry-pick -m 1 "$MERGE_COMMIT_SHA"; then - echo "Cherry-pick with -m 1 successful." - else + if ! git cherry-pick --no-commit -m 1 "$MERGE_COMMIT_SHA"; then echo "Cherry-pick failed." git cherry-pick --abort post_comment "❌ Cherry-pick failed: Conflicts detected when cherry-picking to \`$TARGET_BRANCH\`. Please resolve manually." @@ -127,6 +124,14 @@ jobs: fi fi + # Use PR title as commit message + NEW_COMMIT_MSG="[Cherry-Pick] $PR_TITLE (#$PR_NUMBER)" + # Preserve original author info + GIT_AUTHOR_NAME="$AUTHOR_NAME" \ + GIT_AUTHOR_EMAIL="$AUTHOR_EMAIL" \ + git commit -m "$NEW_COMMIT_MSG" + echo "Created commit with [Cherry-Pick] prefix" + # Push # Construct authenticated URL for the fork FORK_URL_AUTH="https://${BOT_USERNAME}:${GH_TOKEN}@github.com/${REPO_NAME}.git"