forked from Aakvatech-Limited/HMS_TZ
-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (48 loc) · 1.86 KB
/
backport.yml
File metadata and controls
57 lines (48 loc) · 1.86 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
53
54
55
56
name: Backport PR
on:
pull_request_target:
types: [closed, labeled]
permissions:
contents: write
pull-requests: write
jobs:
backport:
name: Backport PR
if: >
github.event.pull_request.merged == true
&& contains(join(github.event.pull_request.labels.*.name, ','), 'backport')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create backport PRs
uses: korthout/backport-action@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
label_pattern: "^backport-to-(.+)$"
# pull_title: "[Backport ${target_branch}] ${pull_title}"
pull_title: "${pull_title}"
pull_description: |
Backport of #${pull_number} to `${target_branch}`.
---
${pull_description}
merge_commits: "skip"
copy_requested_reviewers: true
copy_assignees: true
copy_labels_pattern: "^(?!backport)"
- name: Report backport status
if: failure()
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const pull_number = context.payload.pull_request.number;
await github.rest.issues.createComment({
owner,
repo,
issue_number: pull_number,
body: `⚠️ **Backport failed!**\n\nThe automatic backport could not be completed. This might be due to merge conflicts.\n\nPlease manually cherry-pick the commits to the target branch:\n\n\`\`\`bash\ngit checkout <target-branch>\ngit cherry-pick -x ${context.payload.pull_request.merge_commit_sha}\n\`\`\`\n\nThen create a new PR targeting the branch.`
});