-
Notifications
You must be signed in to change notification settings - Fork 41
36 lines (32 loc) · 1.12 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
name: Cherry Pick
on:
issue_comment:
types: [created]
jobs:
cherry-pick:
runs-on: ubuntu-latest
if: |
startsWith(github.event.comment.body, '/cherry-pick')
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up Git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Extract target branch
id: extract
run: echo "::set-output name=branch::$(echo "${{ github.event.comment.body }}" | cut -d' ' -f2)"
- name: Cherry-pick the PR
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
TARGET_BRANCH=${{ steps.extract.outputs.branch }}
git fetch origin ${{ github.event.pull_request.head.ref }}
git checkout $TARGET_BRANCH
git cherry-pick ${{ github.event.pull_request.head.sha }} || exit 0
- name: Push changes
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
git push https://${GH_PAT}@github.com/${{ github.repository }} $TARGET_BRANCH