8000 CI Check only title for regex labeling (#19303) · scikit-learn/scikit-learn@3325c23 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3325c23

Browse files
authored
CI Check only title for regex labeling (#19303)
1 parent 96a96f1 commit 3325c23

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

.github/labeler.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/scripts/label_title_regex.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""Labels PRs based on title. Must be run in a github action with the
2+
pull_request_target event."""
3+
from ghapi.all import context_github
4+
from ghapi.all import GhApi
5+
from ghapi.all import user_repo
6+
from ghapi.all import github_token
7+
import re
8+
9+
owner, repo = user_repo()
10+
pull_request = context_github.event.pull_request
11+
title = pull_request.title
12+
13+
regex_to_labels = [
14+
(r"\bDOC\b", "Documentation"),
15+
(r"\bCI\b", "Build / CI")
16+
]
17+
18+
labels_to_add = [
19+
label for regex, label in regex_to_labels
20+
if re.search(regex, title)
21+
]
22+
23+
if labels_to_add:
24+
api = GhApi(owner=owner, repo=repo, token=github_token())
25+
api.issues.add_labels(pull_request.number, labels=labels_to_add)
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
name: Pull Request Regex Title Labeler
22
on:
33
pull_request_target:
4-
types: [opened]
4+
types: [opened, edited]
55

66
jobs:
77

88
labeler:
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-20.04
1010
steps:
11-
- name: Check Labels
12-
id: labeler
13-
continue-on-error: true
14-
uses: jimschubert/labeler-action@v2
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-python@v2
1513
with:
16-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
14+
python-version: '3.9'
15+
- name: Install ghapi
16+
run: pip install -Uq ghapi
17+
- name: Label pull request
18+
run: python .github/scripts/label_title_regex.py
19+
env:
20+
CONTEXT_GITHUB: ${{ toJson(github) }}

0 commit comments

Comments
 (0)
0