-
Notifications
You must be signed in to change notification settings - Fork 18
66 lines (58 loc) · 1.83 KB
/
pr-labeler.yml
File metadata and controls
66 lines (58 loc) · 1.83 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
name: PR Auto Labeler
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
jobs:
path-labels:
runs-on: self-hosted
steps:
- name: Apply path-based labels
uses: actions/labeler@v6
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/labeler.yml
quick-fix-label:
runs-on: self-hosted
steps:
- name: Check total changed lines and add quick fix label
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const prNumber = context.payload.pull_request.number;
// List files in PR
const files = await github.paginate(
github.rest.pulls.listFiles,
{
owner,
repo,
pull_number: prNumber,
per_page: 100,
}
);
// Sum additions + deletions
const changed = files.reduce(
(sum, f) => sum + (f.additions || 0) + (f.deletions || 0),
0
);
core.info(`Total changed lines: ${changed}`);
if (changed <= 20) {
try {
await github.rest.issues.addLabels({
owner,
repo,
issue_number: prNumber,
labels: ["quick fix 🚀"],
});
core.info('Added "quick fix 🚀" label.');
} catch (e) {
core.warning(`Failed to add label: ${e.message}`);
}
} else {
core.info("Change exceeds quick fix threshold; not labeling.");
}