forked from kserve/kserve
-
Notifications
You must be signed in to change notification settings - Fork 50
52 lines (43 loc) · 1.81 KB
/
comment-cherry-pick.yml
File metadata and controls
52 lines (43 loc) · 1.81 KB
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
name: Cherry Pick On Comment
on:
issue_comment:
types: [created]
jobs:
validate:
name: Validate Cherry Pick Request
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/cherry-pick') && (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR')
runs-on: ubuntu-latest
steps:
- name: Check if PR is merged
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER="${{ github.event.issue.number }}"
PR_STATE=$(gh pr view "$PR_NUMBER" --json state -q .state)
PR_MERGED=$(gh pr view "$PR_NUMBER" --json mergedAt -q .mergedAt)
if [[ "$PR_STATE" != "MERGED" ]] || [[ "$PR_MERGED" == "null" ]]; then
echo "❌ Error: PR #$PR_NUMBER is not merged yet"
echo " Current state: $PR_STATE"
echo " Cherry-pick can only be performed on merged PRs"
exit 1
fi
echo "✅ PR #$PR_NUMBER is merged"
cherry-pick:
name: Cherry Pick
needs: validate
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Fetch PR commits
run: |
PR_NUMBER="${{ github.event.issue.number }}"
echo "Fetching PR #$PR_NUMBER commits"
git fetch origin "pull/$PR_NUMBER/head:pr-$PR_NUMBER"
- name: Automatic Cherry Pick
uses: hianhianhian/gha-cherry-pick@c88f57e55a9eabd96f94edba6d584b37633836d1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}