Skip to content

Commit 775a2af

Browse files
committed
Add issue auto-labeler workflow
1 parent a2a7cf9 commit 775a2af

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Issue Auto Labeler
2+
3+
on:
4+
issues:
5+
types: [opened, edited, reopened]
6+
7+
permissions:
8+
issues: write
9+
10+
jobs:
11+
label:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Apply area labels
15+
uses: actions/github-script@v7
16+
with:
17+
script: |
18+
const issue = context.payload.issue;
19+
const text = `${issue.title}\n${issue.body || ''}`.toLowerCase();
20+
const rules = [
21+
{ label: 'area: docs', re: /(\bdoc\b|\bdocs\b|documentation|readme|guide|tutorial)/ },
22+
{ label: 'area: spec', re: /(\bspec\b|specification|grammar)/ },
23+
{ label: 'area: parser', re: /(parser|parse|parsing|syntax)/ },
24+
{ label: 'area: interpreter', re: /(interpreter|runtime|eval|evaluator)/ },
25+
{ label: 'area: typechecker', re: /(type checker|typechecker|typing|\btypes?\b)/ },
26+
{ label: 'area: cli', re: /(\bcli\b|command line|terminal|shell)/ },
27+
];
28+
29+
const labels = new Set();
30+
for (const rule of rules) {
31+
if (rule.re.test(text)) {
32+
labels.add(rule.label);
33+
}
34+
}
35+
36+
if (labels.size === 0) {
37+
return;
38+
}
39+
40+
await github.rest.issues.addLabels({
41+
...context.repo,
42+
issue_number: issue.number,
43+
labels: Array.from(labels),
44+
});

0 commit comments

Comments
 (0)