-
Notifications
You must be signed in to change notification settings - Fork 2
86 lines (74 loc) Β· 2.63 KB
/
assign-auto-label.yml
File metadata and controls
86 lines (74 loc) Β· 2.63 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
81
82
83
84
85
86
name: Auto Labeler
on:
issues:
types: [opened]
pull_request_target:
types: [opened, reopened]
branches: [develop]
jobs:
labeler:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Auto Labeling based on title
if: github.event_name == 'pull_request_target' || github.event_name == 'issues'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const payload = context.payload;
const isPR = !!payload.pull_request;
const target = isPR ? payload.pull_request : payload.issue;
const title = target.title;
const author = target.user.login;
const issueNumber = target.number;
const labelsToAdd = [];
const labelPatterns = {
'π Fix': /\b(fix|Fix|FIX)\b/i,
'β¨ Feature': /\b(feat|Feat|FEAT)\b/i,
'π Docs': /\b(docs|Docs|DOCS)\b/i,
'βοΈ Init': /\b(init|Init|INIT)\b/i,
'π¨ Design': /\b(design|Design|DESIGN)\b/i,
'π§ Chore': /\b(chore|Chore|CHORE)\b/i,
'β»οΈ Refactor': /\b(refactor|Refactor|REFACTOR)\b/i,
'π₯ Hotfix': /\b(hotfix|Hotfix|HOTFIX)\b/i,
'π Deploy': /\b(deploy|Deploy|DEPLOY)\b/i
};
for (const [label, pattern] of Object.entries(labelPatterns)) {
if (pattern.test(title)) {
labelsToAdd.push(label);
}
}
const userLabels = {
"Sohyunnnn": "π° μν",
"jisooooooooooo": "π΅ μ§μ",
"jin-evergreen": "π»ββοΈ μ§μ",
"eunkr82": "π± λμ"
};
if (userLabels[author]) {
labelsToAdd.push(userLabels[author]);
}
const uniqueLabels = [...new Set(labelsToAdd)];
if (uniqueLabels.length > 0) {
try {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: uniqueLabels
});
} catch (error) {
}
}
try {
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
assignees: [author]
});
} catch (error) {
}