-
Notifications
You must be signed in to change notification settings - Fork 68
53 lines (47 loc) · 1.63 KB
/
autolabeler.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
name: Auto Labeler
on:
issues:
types: [opened, edited]
pull_request:
types: [opened, edited]
jobs:
labeler:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Label issues and PRs
uses: actions/github-script@v6
with:
script: |
const issue = context.payload.issue || context.payload.pull_request;
const labels = [];
// Define keywords and their associated labels
const labelMappings = {
'bug': 'bug',
'enhancement': 'enhancement',
'feature': 'feature',
'good first issue': 'good first issue',
'ui': 'ui',
'hacktoberfest': 'hacktoberfest',
'hacktoberfest-accepted': 'hacktoberfest-accepted',
'documentation': 'documentation',
'gssoc-ext': 'gssoc-ext',
'workflow': 'workflow',
'automation': 'automation',
// Add more mappings as needed
};
// Apply labels based on title or body content
for (const [keyword, label] of Object.entries(labelMappings)) {
if (issue.title.toLowerCase().includes(keyword) || issue.body.toLowerCase().includes(keyword)) {
labels.push(label);
}
}
if (labels.length > 0) {
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: labels
});
}