-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (66 loc) · 2.36 KB
/
Copy pathlabel-pr.yml
File metadata and controls
80 lines (66 loc) · 2.36 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Label PR
on:
pull_request:
types: [opened, edited, reopened]
permissions:
pull-requests: write
contents: read
jobs:
label:
name: Auto Label PR
runs-on: ubuntu-latest
steps:
- name: Label based on PR title
uses: actions/github-script@v7
with:
script: |
const title = context.payload.pull_request.title.toLowerCase();
const labels = [];
// Feature detection
if (title.includes('feat') || title.includes('feature') || title.includes('add')) {
labels.push('feature');
}
// Bug detection
if (title.includes('fix') || title.includes('bug')) {
labels.push('bug');
}
// Documentation detection
if (title.includes('doc') || title.includes('readme')) {
labels.push('documentation');
}
// Refactor detection
if (title.includes('refactor') || title.includes('cleanup')) {
labels.push('refactor');
}
// Test detection
if (title.includes('test')) {
labels.push('test');
}
// Performance detection
if (title.includes('perf') || title.includes('performance') || title.includes('optim')) {
labels.push('performance');
}
// Breaking change detection
if (title.includes('breaking') || title.includes('!')) {
labels.push('breaking-change');
}
// Maintenance detection
if (title.includes('chore') || title.includes('maintenance') || title.includes('deps')) {
labels.push('maintenance');
}
// Security detection
if (title.includes('security') || title.includes('vuln')) {
labels.push('security');
}
// Apply labels if any were found
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: labels
});
console.log(`Applied labels: ${labels.join(', ')}`);
} else {
console.log('No matching labels found');
}