-
Notifications
You must be signed in to change notification settings - Fork 1.9k
126 lines (109 loc) · 4.25 KB
/
pr-checker.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: PR CHECKER
on:
pull_request_target:
branches:
- main
- 'branch-[0-9].[0-9]'
types:
- opened
- reopened
- edited
jobs:
sync-checker:
runs-on: ubuntu-latest
if: >
!contains(github.event.pull_request.title, '(sync #') &&
!contains(github.event.pull_request.labels.*.name, 'sync') &&
(!startsWith(github.head_ref, github.base_ref) || !contains(github.head_ref, '-sync-'))
name: SYNC CHECKER
steps:
- run: echo "Normal PR."
title-check:
runs-on: ubuntu-latest
needs: sync-checker
steps:
- uses: thehanimo/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pass_on_octokit_error: false
configuration_path: ".github/pr-title-checker-config.json"
backport-check:
needs: title-check
runs-on: ubuntu-latest
if: >
(startsWith(github.event.pull_request.title, '[BugFix]') ||
startsWith(github.event.pull_request.title, '[Enhancement]'))&&
!contains(github.event.pull_request.title, 'cherry-pick') &&
!contains(github.event.pull_request.title, 'backport')
steps:
- name: add branch-3.1 label
if: contains(toJson(github.event.pull_request.body), '[x] 3.1')
uses: actions-ecosystem/action-add-labels@v1
with:
labels: '3.1'
- name: add branch-3.0 label
if: contains(toJson(github.event.pull_request.body), '[x] 3.0')
uses: actions-ecosystem/action-add-labels@v1
with:
labels: '3.0'
- name: add branch-2.5 label
if: contains(toJson(github.event.pull_request.body), '[x] 2.5')
uses: actions-ecosystem/action-add-labels@v1
with:
labels: '2.5'
- name: add branch-2.4 label
if: contains(toJson(github.event.pull_request.body), '[x] 2.4')
uses: actions-ecosystem/action-add-labels@v1
with:
labels: '2.4'
- name: remove branch-3.1 label
if: contains(toJson(github.event.pull_request.body), '[ ] 3.1') && contains(github.event.pull_request.labels.*.name, '3.1')
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: '3.1'
- name: remove branch-3.0 label
if: contains(toJson(github.event.pull_request.body), '[ ] 3.0') && contains(github.event.pull_request.labels.*.name, '3.0')
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: '3.0'
- name: remove branch-2.5 label
if: contains(toJson(github.event.pull_request.body), '[ ] 2.5') && contains(github.event.pull_request.labels.*.name, '2.5')
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: '2.5'
- name: remove branch-2.4 label
if: contains(toJson(github.event.pull_request.body), '[ ] 2.4') && contains(github.event.pull_request.labels.*.name, '2.4')
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: '2.4'
- name: check-done
if: >
(startsWith(github.event.pull_request.title, '[BugFix]') ||
startsWith(github.event.pull_request.title, '[Enhancement]'))&&
!contains(github.event.pull_request.title, 'cherry-pick') &&
!contains(github.event.pull_request.title, 'backport') &&
contains(toJson(github.event.pull_request.body), '[ ] I have checked the version labels')
run: |
echo "You must mark this checkbox - I have checked the version labels which the pr will be auto-backported to the target branch"
exit 1
automerge-check:
runs-on: ubuntu-latest
needs: backport-check
if: >
!failure() &&
github.base_ref != 'main' &&
startsWith(github.head_ref, 'mergify/') &&
(contains(github.event.pull_request.title, 'cherry-pick') ||
contains(github.event.pull_request.title, 'backport'))
steps:
- name: add automerge label
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.PAT }}
labels: automerge
- name: automerge
uses: peter-evans/enable-pull-request-automerge@v2
with:
token: ${{ secrets.PAT }}
pull-request-number: ${{ github.event.pull_request.number }}
merge-method: rebase