Skip to content

Commit 6e9b35a

Browse files
v1vmashhurs
andauthored
mergify: support backports automation with labels (#248)
* mergify: support backports automation with labels * fix * update mergify use what it has been enabled in logstash * Update .mergify.yml Co-authored-by: Mashhur <[email protected]> --------- Co-authored-by: Mashhur <[email protected]>
1 parent 601ae04 commit 6e9b35a

File tree

5 files changed

+212
-1
lines changed

5 files changed

+212
-1
lines changed

.buildkite/pull-requests.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))",
1313
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))",
1414
"skip_target_branches": [],
15-
"skip_ci_on_only_changed": ["^docs/"],
15+
"skip_ci_on_only_changed": ["^.github/", "^docs/", "^.mergify.yml", "^.pre-commit-config.yaml"],
1616
"always_require_ci_on_changed": [],
1717
"skip_ci_labels": []
1818
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: mergify backport labels copier
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
mergify-backport-labels-copier:
13+
runs-on: ubuntu-latest
14+
if: startsWith(github.head_ref, 'mergify/bp/')
15+
permissions:
16+
# Add GH labels
17+
pull-requests: write
18+
# See https://github.com/cli/cli/issues/6274
19+
repository-projects: read
20+
steps:
21+
- uses: elastic/oblt-actions/mergify/labels-copier@v1
22+
with:
23+
excluded-labels-regex: "^backport-*"

.github/workflows/pre-commit.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- 8.*
9+
- 9.*
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
pre-commit:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: elastic/oblt-actions/pre-commit@v1

.mergify.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
pull_request_rules:
2+
- name: notify the backport policy
3+
conditions:
4+
- -label~=^backport
5+
- base=main
6+
actions:
7+
comment:
8+
message: |
9+
This pull request does not have a backport label. Could you fix it @{{author}}? 🙏
10+
To fixup this pull request, you need to add the backport labels for the needed
11+
branches, such as:
12+
* `backport-8./d` is the label to automatically backport to the `8./d` branch. `/d` is the digit.
13+
* `backport-8.x` is the label to automatically backport to the `8.x` branch.
14+
* If no backport is necessary, please add the `backport-skip` label
15+
16+
- name: remove backport-skip label
17+
conditions:
18+
- label~=^backport-\d
19+
actions:
20+
label:
21+
remove:
22+
- backport-skip
23+
24+
- name: notify the backport has not been merged yet
25+
conditions:
26+
- -merged
27+
- -closed
28+
- author=mergify[bot]
29+
- "#check-success>0"
30+
- schedule=Mon-Mon 06:00-10:00[Europe/Paris]
31+
actions:
32+
comment:
33+
message: |
34+
This pull request has not been merged yet. Could you please review and merge it @{{ assignee | join(', @') }}? 🙏
35+
36+
- name: backport patches to 8.x branch
37+
conditions:
38+
- merged
39+
- base=main
40+
- label=backport-8.x
41+
actions:
42+
backport:
43+
assignees:
44+
- "{{ author }}"
45+
branches:
46+
- "8.x"
47+
labels:
48+
- "backport"
49+
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"
50+
51+
- name: backport patches to 8.16 branch
52+
conditions:
53+
- merged
54+
- base=main
55+
- label=backport-8.16
56+
actions:
57+
backport:
58+
assignees:
59+
- "{{ author }}"
60+
branches:
61+
- "8.16"
62+
labels:
63+
- "backport"
64+
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"
65+
66+
- name: backport patches to 8.17 branch
67+
conditions:
68+
- merged
69+
- base=main
70+
- label=backport-8.17
71+
actions:
72+
backport:
73+
assignees:
74+
- "{{ author }}"
75+
branches:
76+
- "8.17"
77+
labels:
78+
- "backport"
79+
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"
80+
81+
- name: backport patches to 8.18 branch
82+
conditions:
83+
- merged
84+
- base=main
85+
- label=backport-8.18
86+
actions:
87+
backport:
88+
assignees:
89+
- "{{ author }}"
90+
branches:
91+
- "8.18"
92+
labels:
93+
- "backport"
94+
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"
95+
96+
- name: backport patches to 9.0 branch
97+
conditions:
98+
- merged
99+
- base=main
100+
- label=backport-9.0
101+
actions:
102+
backport:
103+
assignees:
104+
- "{{ author }}"
105+
branches:
106+
- "9.0"
107+
labels:
108+
- "backport"
109+
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"
110+
111+
- name: backport patches to all active minor branches for the 8 major.
112+
conditions:
113+
- merged
114+
- label=backport-active-8
115+
actions:
116+
backport:
117+
assignees:
118+
- "{{ author }}"
119+
# NOTE: this list needs to be changed when a new minor branch is created
120+
# or an existing minor branch reached EOL.
121+
branches:
122+
- "8.x"
123+
- "8.18"
124+
- "8.17"
125+
- "8.16"
126+
labels:
127+
- "backport"
128+
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"
129+
130+
- name: backport patches to all active minor branches for the 9 major.
131+
conditions:
132+
- merged
133+
- label=backport-active-9
134+
actions:
135+
backport:
136+
assignees:
137+
- "{{ author }}"
138+
# NOTE: this list needs to be changed when a new minor branch is created
139+
# or an existing minor branch reached EOL.
140+
branches:
141+
- "9.0"
142+
labels:
143+
- "backport"
144+
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"
145+
146+
- name: backport patches to all active branches
147+
conditions:
148+
- merged
149+
- label=backport-active-all
150+
actions:
151+
backport:
152+
assignees:
153+
- "{{ author }}"
154+
# NOTE: this list needs to be changed when a new minor branch is created
155+
# or an existing release branch reached EOL.
156+
branches:
157+
- "9.0"
158+
- "8.18"
159+
- "8.17"
160+
- "8.16"
161+
- "8.x"
162+
labels:
163+
- "backport"
164+
title: "[{{ destination_branch }}] {{ title }} (backport #{{ number }})"

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: check-merge-conflict
6+
args: ['--assume-in-merge']

0 commit comments

Comments
 (0)