-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (31 loc) · 1.26 KB
/
pull-request-labels.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
name: Pull Request Labels
on:
pull_request:
types: [opened]
jobs:
pull-request-labeler:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Add label to pull request
uses: actions/github-script@v6
with:
script: |
const title = context.payload.pull_request.title.toLowerCase();
if (!title) return;
function getLabelFromTitle(title) {
if (title.includes('feat!:')) return 'breaking change';
if (title.includes('fix:')) return 'fix';
if (title.includes('feat:')) return 'feature';
return null;
}
const label = getLabelFromTitle(title);
if (label) {
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [label]
});
}