-
Notifications
You must be signed in to change notification settings - Fork 12
64 lines (55 loc) · 1.98 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Cherry Pick
on:
workflow_call:
jobs:
branches:
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.cherry_pick_branches.outputs.result }}
steps:
- name: Check for cherry-pick labels
id: cherry_pick_branches
uses: actions/github-script@v7
with:
script: |
const { data: issue } = await github.rest.issues.get({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const labels = issue.labels.map(label => label.name);
console.log(`Labels: ${labels}`);
const branches = labels.filter(label => label.startsWith('cherry-pick/'))
.map(label => label.substr(12));
console.log(`Branches: ${branches}`);
return branches
cherry-pick:
runs-on: ubuntu-latest
needs: branches
if: ${{ needs.branches.outputs.branches != '[]' && needs.branches.outputs.branches != '' }}
strategy:
matrix:
branch: ${{ fromJson(needs.branches.outputs.branches) }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
fetch-depth: 0
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v3
with:
application_id: ${{ vars.KONVEYOR_BOT_ID }}
application_private_key: ${{ secrets.KONVEYOR_BOT_KEY }}
- name: Cherry-pick
env:
GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
run: |
BRANCH_NAME="cherry-pick-pr${{ github.event.number }}-${{ matrix.branch }}"
git config --global user.email "[email protected]"
git config --global user.name "Cherry Picker"
git checkout -b ${BRANCH_NAME}
git cherry-pick -s ${{ github.sha }}
git push origin ${BRANCH_NAME}
gh pr create --base ${{ matrix.branch }} --fill