-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some
spring-cherry-pick.yml
clean up
* Expose `Auto-cherry-pick to` token as a `spring-cherry-pick.yml` workflow `autoCherryPickMessage` input
- Loading branch information
1 parent
4b53f52
commit aa5418e
Showing
1 changed file
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,12 @@ name: Automatically cherry-pick commit | |
|
||
on: | ||
workflow_call: | ||
inputs: | ||
autoCherryPickToken: | ||
description: 'The sub-string in the commit message to determine that commit has to be cherry-picked' | ||
required: false | ||
default: Auto-cherry-pick to | ||
type: string | ||
|
||
secrets: | ||
GH_ACTIONS_REPO_TOKEN: | ||
|
@@ -13,20 +19,23 @@ env: | |
jobs: | ||
cherry-pick: | ||
runs-on: ubuntu-latest | ||
if: contains(github.event.head_commit.message, 'Auto-cherry-pick to') | ||
if: contains(github.event.head_commit.message, inputs.autoCherryPickToken) | ||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
with: | ||
token: ${{ env.GITHUB_TOKEN }} | ||
show-progress: false | ||
fetch-depth: 0 | ||
|
||
- name: Cherry-pick to branches in commit message | ||
run: | | ||
git config --global user.name 'Spring Builds' | ||
git config --global user.email '[email protected]' | ||
branches=$(echo '${{ github.event.head_commit.message }}' | grep 'Auto-cherry-pick to' | grep -o1 -E "([0-9]+\.[0-9]+\.x)") | ||
branchCommitMessage=$(echo '${{ github.event.head_commit.message }}' | grep -v 'Auto-cherry-pick to') | ||
cherryPickToken=${{ inputs.autoCherryPickToken }} | ||
commitMessage=${{ github.event.head_commit.message }} | ||
branches=$(echo '$commitMessage' | grep '$cherryPickToken' | grep -o1 -E "([0-9]+\.[0-9]+\.x)") | ||
branchCommitMessage=$(echo '$commitMessage' | grep -v '$cherryPickToken') | ||
for branch in $branches | ||
do | ||
git checkout $branch | ||
|
@@ -38,5 +47,5 @@ jobs: | |
exit 1 | ||
fi | ||
git commit –amend -m $branchCommitMessage | ||
git push origin $branch | ||
git push $branch | ||
done |