-
Notifications
You must be signed in to change notification settings - Fork 2.4k
54 lines (46 loc) · 1.55 KB
/
labeler.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Label PR
on:
pull_request:
types: [ opened, edited, reopened, synchronize ]
permissions:
issues: write
pull-requests: write
jobs:
labeler:
runs-on: ubuntu-latest
steps:
- name: Label PR size
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const prNumber = context.payload.pull_request.number;
const { data: prData } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
const additions = prData.additions;
const deletions = prData.deletions;
const totalChanges = additions + deletions;
let label = "";
if (totalChanges < 10) {
label = "size:XS";
} else if (totalChanges < 100) {
label = "size:S";
} else if (totalChanges < 300) {
label = "size:M";
} else if (totalChanges < 1000) {
label = "size:L";
} else {
label = "size:XL";
}
// Apply the label
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: [label],
});
console.log(`Total lines of changes: ${totalChanges}`);
console.log(`Label: ${label}`);