From aa5418e4e5b115809725fa779bc5eebb5d7c85a5 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 8 Feb 2024 15:09:07 -0500 Subject: [PATCH] Some `spring-cherry-pick.yml` clean up * Expose `Auto-cherry-pick to` token as a `spring-cherry-pick.yml` workflow `autoCherryPickMessage` input --- .github/workflows/spring-cherry-pick.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/spring-cherry-pick.yml b/.github/workflows/spring-cherry-pick.yml index a9475f5..7872abc 100644 --- a/.github/workflows/spring-cherry-pick.yml +++ b/.github/workflows/spring-cherry-pick.yml @@ -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 '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 @@ -38,5 +47,5 @@ jobs: exit 1 fi git commit –amend -m $branchCommitMessage - git push origin $branch + git push $branch done