Skip to content

Commit aa5418e

Browse files
committed
Some spring-cherry-pick.yml clean up
* Expose `Auto-cherry-pick to` token as a `spring-cherry-pick.yml` workflow `autoCherryPickMessage` input
1 parent 4b53f52 commit aa5418e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

.github/workflows/spring-cherry-pick.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: Automatically cherry-pick commit
22

33
on:
44
workflow_call:
5+
inputs:
6+
autoCherryPickToken:
7+
description: 'The sub-string in the commit message to determine that commit has to be cherry-picked'
8+
required: false
9+
default: Auto-cherry-pick to
10+
type: string
511

612
secrets:
713
GH_ACTIONS_REPO_TOKEN:
@@ -13,20 +19,23 @@ env:
1319
jobs:
1420
cherry-pick:
1521
runs-on: ubuntu-latest
16-
if: contains(github.event.head_commit.message, 'Auto-cherry-pick to')
22+
if: contains(github.event.head_commit.message, inputs.autoCherryPickToken)
1723
steps:
1824

1925
- uses: actions/checkout@v4
2026
with:
2127
token: ${{ env.GITHUB_TOKEN }}
2228
show-progress: false
29+
fetch-depth: 0
2330

2431
- name: Cherry-pick to branches in commit message
2532
run: |
2633
git config --global user.name 'Spring Builds'
2734
git config --global user.email 'builds@springframework.org'
28-
branches=$(echo '${{ github.event.head_commit.message }}' | grep 'Auto-cherry-pick to' | grep -o1 -E "([0-9]+\.[0-9]+\.x)")
29-
branchCommitMessage=$(echo '${{ github.event.head_commit.message }}' | grep -v 'Auto-cherry-pick to')
35+
cherryPickToken=${{ inputs.autoCherryPickToken }}
36+
commitMessage=${{ github.event.head_commit.message }}
37+
branches=$(echo '$commitMessage' | grep '$cherryPickToken' | grep -o1 -E "([0-9]+\.[0-9]+\.x)")
38+
branchCommitMessage=$(echo '$commitMessage' | grep -v '$cherryPickToken')
3039
for branch in $branches
3140
do
3241
git checkout $branch
@@ -38,5 +47,5 @@ jobs:
3847
exit 1
3948
fi
4049
git commit –amend -m $branchCommitMessage
41-
git push origin $branch
50+
git push $branch
4251
done

0 commit comments

Comments
 (0)