-
Notifications
You must be signed in to change notification settings - Fork 4
46 lines (42 loc) · 1.56 KB
/
pr-auto-assign-and-label.yml
File metadata and controls
46 lines (42 loc) · 1.56 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
name: 🤖 Auto-assign & label PR
on:
pull_request:
types: [opened]
permissions:
pull-requests: write
issues: write
jobs:
auto:
runs-on: ubuntu-latest
steps:
- name: Auto assign author & reviewers
uses: kentaro-m/auto-assign-action@v1.2.5
with:
configuration-path: .github/auto_assign.yml
- name: Label by title keywords
uses: actions/github-script@v7
with:
script: |
const title = context.payload.pull_request.title.toLowerCase();
const rules = [
{ re: /\bfeat|feature\b/, label: 'feature' },
{ re: /\bfix\b/, label: 'fix' },
{ re: /\bbug\b/, label: 'bug' },
{ re: /\bstyle\b/, label: 'style' },
{ re: /\brefactor\b/, label: 'refactor' },
{ re: /\bchore\b/, label: 'chore' },
{ re: /\bdocs?\b/, label: 'docs' },
{ re: /\btest(s)?\b/, label: 'test' },
];
const matched = rules.filter(r => r.re.test(title)).map(r => r.label);
if (matched.length) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: matched
});
core.info(`Added labels: ${matched.join(', ')}`);
} else {
core.info('No matching labels from title.');
}