-
-
Notifications
You must be signed in to change notification settings - Fork 2
52 lines (45 loc) · 1.49 KB
/
Copy pathlabel.yml
File metadata and controls
52 lines (45 loc) · 1.49 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
name: Label PR
on:
pull_request_target:
branches: [master]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
labeler:
name: Label PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
# File-based labels (docs, ci, deps, plugins)
- uses: actions/labeler@v7
with:
configuration-path: .github/labeler.yml
# Conventional commit labels from PR title
- name: Label from PR title
uses: actions/github-script@v9
with:
script: |
const title = context.payload.pull_request.title.toLowerCase();
const labels = [];
if (title.startsWith('feat:') || title.startsWith('feat(') || title.startsWith('feature:') || title.startsWith('feature(')) {
labels.push('feature');
}
if (title.startsWith('fix:') || title.startsWith('fix(')) {
labels.push('bug');
}
if (title.startsWith('docs:') || title.startsWith('docs(')) {
labels.push('documentation');
}
if (title.startsWith('chore:') || title.startsWith('chore(')) {
labels.push('chore');
}
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,
});
}