-
Notifications
You must be signed in to change notification settings - Fork 15
50 lines (42 loc) · 1.6 KB
/
ci-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
name: Cherry-Pick to Release Branch
on:
push:
branches:
- pla-1142
run-name: Cherry pick `${{ github.sha }}` to release branch
jobs:
cherry-pick:
if: contains(github.event.head_commit.message, '[pick]')
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v3
- name: Configure Git
run: |
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
- name: Cherry-pick commit
run: |
set -x
git fetch --all
RELEASE_BRANCH=$(git branch -r | grep 'origin/release/[0-9]\+\.[0-9]' | sed 's/.*release\///' | sort -V | tail -n1)
echo "RELEASE_BRANCH=release/$RELEASE_BRANCH" >> $GITHUB_ENV
BRANCH=pick/non-breaking-$(date +%s)
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
COMMIT_SHA=$(git rev-parse HEAD)
git checkout $RELEASE_BRANCH
git checkout -b $BRANCH
git cherry-pick -x $COMMIT_SHA
- name: Push to Remote
run: |
git push origin ${{ env.BRANCH }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.CF_BACKEND_GITHUB_TOKEN }}
commit-message: Cherry-picked from ${{ github.event.pull_request.head.sha }}
title: "Cherry-Pick: ${{ github.event.pull_request.title }}"
branch: ${{ env.BRANCH }}
base: '${{ env.RELEASE_BRANCH }}' # Update with your current release branch
reviewers: 'martin-chainflip'
labels: cherry-pick