Skip to content

Commit

Permalink
Some spring-cherry-pick.yml clean up
Browse files Browse the repository at this point in the history
* Expose `Auto-cherry-pick to` token as a `spring-cherry-pick.yml` workflow `autoCherryPickMessage` input
  • Loading branch information
artembilan committed Feb 8, 2024
1 parent 4b53f52 commit aa5418e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/spring-cherry-pick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 'builds@springframework.org'
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
Expand All @@ -38,5 +47,5 @@ jobs:
exit 1
fi
git commit –amend -m $branchCommitMessage
git push origin $branch
git push $branch
done

0 comments on commit aa5418e

Please sign in to comment.