-
Notifications
You must be signed in to change notification settings - Fork 590
50 lines (47 loc) · 1.73 KB
/
cherry-pick-to-release-branch.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
41
42
43
44
45
46
47
48
49
50
name: PR for release branch
on:
pull_request:
branches:
- main
types: ["closed", "labeled"]
jobs:
get-release-branches:
if: |
github.event.pull_request.merged &&
((github.event.action == 'labeled' && startsWith(github.event.label.name, 'need-cherry-pick')) ||
(github.event.action == 'closed' && contains(toJson(github.event.pull_request.labels), 'need-cherry-pick')))
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.get-release-branches.outputs.branches }}
steps:
- name: Get release branches
id: get-release-branches
run: |
if [[ ${{ github.event.action }} == 'labeled' ]]; then
echo "branches=[\"$(echo ${{ github.event.label.name }} | cut -d '-' -f 4-)\"]" >> "$GITHUB_OUTPUT"
else
labels='${{ toJson(github.event.pull_request.labels) }}'
echo branches=$(echo "$labels" | jq -r '.[] | select(.name | contains("need-cherry-pick")).name' | cut -d '-' -f 4- | jq --raw-input . | jq --slurp . -c) >> "$GITHUB_OUTPUT"
fi
release_pull_request:
needs:
- get-release-branches
runs-on: ubuntu-latest
strategy:
matrix:
branch: ${{ fromJson(needs.get-release-branches.outputs.branches) }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: Create PR to branch
uses: risingwavelabs/github-action-cherry-pick@master
with:
pr_branch: ${{ matrix.branch }}
pr_labels: 'cherry-pick'
pr_body: ${{ format('Cherry picking \#{0} onto branch {1}', github.event.number, matrix.branch) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
issues: write
pull-requests: write
contents: write