-
Notifications
You must be signed in to change notification settings - Fork 115
40 lines (37 loc) · 1.47 KB
/
auto_cherry_pick.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# CI stages to execute against all branches on PR merge
name: auto_cherry_pick_commits
on:
pull_request_target:
types:
- closed
jobs:
previous-branch:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CherryPick')
name: Calculate previous branch name
runs-on: ubuntu-latest
outputs:
previous_branch: ${{ steps.set-branch.outputs.previous_branch }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: set-branch
run: echo "::set-output name=previous_branch::$(if [ $GITHUB_BASE_REF == 'master' ]; then echo $(git branch -rl --sort=-authordate 'origin/6.*.z' --format='%(refname:lstrip=-1)' | head -n1 | jq -cnR '[inputs | select(length>0)]'); else echo ['"6.'$(($(echo $GITHUB_BASE_REF | cut -d. -f2) - 1))'.z"']; fi)"
auto-cherry-pick:
name: Auto Cherry Pick to previous branch
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CherryPick')
needs: previous-branch
runs-on: ubuntu-latest
strategy:
matrix:
to_branch: ${{ fromJson(needs.previous-branch.outputs.previous_branch) }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cherry pick into ${{ matrix.to_branch }}
uses: jyejare/github-cherry-pick-action@main
with:
branch: ${{ matrix.to_branch }}
labels: |
Auto_Cherry_Picked