Skip to content

Commit

Permalink
ci: preserve Original Author in Cherry-Picked Commits (#2392) (#2394)
Browse files Browse the repository at this point in the history
* fix: preserve Original Author in Cherry-Picked Commits

* add conflicted files

Co-authored-by: Mohamad Jaara <[email protected]>
  • Loading branch information
github-actions[bot] and MohamadJaara authored Jan 23, 2024
1 parent ee72866 commit 78ff1ac
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/cherry-pick-rc-to-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ jobs:
CHERRY_PICK_COMMIT=$(git rev-parse HEAD)
echo "cherryPickCommit=$CHERRY_PICK_COMMIT" >> $GITHUB_ENV
- name: Get Original Author
id: get-author
if: env.shouldCherryPick == 'true'
run: |
ORIGINAL_AUTHOR=$(git log -1 --pretty=format:'%an <%ae>' ${{ github.event.pull_request.merge_commit_sha }})
echo "Original author: $ORIGINAL_AUTHOR"
echo "originalAuthor=$ORIGINAL_AUTHOR" >> $GITHUB_ENV
- name: Cherry-pick commits
id: commit-cherry-pick
if: env.shouldCherryPick == 'true'
Expand All @@ -122,8 +130,10 @@ jobs:
CONFLICTED_FILES=$(git diff --name-only --diff-filter=U | awk 'ORS="\\\\n"' | sed 's/\\\\n$/\\n/')
echo "Captured conflicted files: $CONFLICTED_FILES"
if [[ "$OUTPUT" == *"CONFLICT"* ]]; then
# Commit the remaining conflicts
git commit -am "Commit with unresolved merge conflicts outside of ${{ env.SUBMODULE_NAME }}"
git add .
git commit --author "${{ env.originalAuthor }}" -am "Commit with unresolved merge conflicts outside of ${{ env.SUBMODULE_NAME }}"
else
git commit --author "${{ env.originalAuthor }}" --amend --no-edit
fi
# Push branch and remove temp
Expand All @@ -133,6 +143,7 @@ jobs:
git branch -D temp-branch-for-cherry-pick
fi
- name: Create PR
if: env.shouldCherryPick == 'true'
env:
Expand Down

0 comments on commit 78ff1ac

Please sign in to comment.