-
Notifications
You must be signed in to change notification settings - Fork 356
45 lines (42 loc) · 1.48 KB
/
backport.yaml
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
name: backport
on:
pull_request_target:
types:
- closed
- labeled
jobs:
backport_and_merge:
runs-on: ubuntu-latest
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
permissions:
contents: write
pull-requests: write
if: |
github.event.pull_request.merged && (
github.event.action == 'closed' || (
github.event.action == 'labeled' && contains(github.event.label.name, 'backport')
)
)
steps:
- name: backport PR
uses: tibdex/backport@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
title_template: "[AUTO-BACKPORT <%= number %>] <%= title %>"
- name: wait-for-checks
uses: poseidon/wait-for-status-checks@v0.5.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: merge backported PR
id: merge_backport_pr
if: success()
run: |
PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --search "[AUTO-BACKPORT ${{ github.event.pull_request.number }}]" --json number --jq '.[0].number')
if [ -n "$PR_NUMBER" ]; then
gh pr merge $PR_NUMBER --merge --repo ${{ github.repository }} --admin -t "Auto-merged backport PR."
else
echo "No backport PR found to merge."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}