-
Notifications
You must be signed in to change notification settings - Fork 5
42 lines (38 loc) · 1.37 KB
/
issue-labeler.yml
File metadata and controls
42 lines (38 loc) · 1.37 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
name: Label Issues
on:
issues:
types: [opened, edited]
jobs:
label:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const title = context.payload.issue.title.toLowerCase();
const body = (context.payload.issue.body || '').toLowerCase();
const text = title + ' ' + body;
const labels = [];
if (/\b(bug|error|crash|broken|fail|problem|not working)\b/.test(text)) {
labels.push('bug');
}
if (/\b(feature|enhancement|request|add|improve|suggest)\b/.test(text)) {
labels.push('enhancement');
}
if (/\b(doc|documentation|readme|guide|example)\b/.test(text)) {
labels.push('documentation');
}
if (/\b(question|help wanted)\b/.test(text) || /\bhow (to|do|does|can)\b/.test(text)) {
labels.push('question');
}
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
labels: labels
});
}