-
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (72 loc) · 2.49 KB
/
label-pr-size.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
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
name: size-label
on:
pull_request_target:
types: [opened, synchronize]
jobs:
size-label:
permissions:
contents: read
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- name: Determine PR size and add label
id: size-label
uses: 'pascalgn/[email protected]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
sizes: >
{
"0": XS,
"20": S,
"50": M,
"200": L,
"800": XL,
"2000": XXL,
}
- name: Set label colors
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labelsToColor = {
XS: 'd4c5f9', // Light purple
S: 'c2e0c6', // Light green
M: 'f9d0c4', // Light red
L: 'f7c6c7', // Light pink
XL: 'fef2c0', // Light yellow
XXL: 'e99695', // Light coral
};
const sizeLabel = core.getInput('size-label-output') || '${{ steps.size-label.outputs.sizeLabel }}';
const color = labelsToColor[sizeLabel];
if (sizeLabel) {
try {
// Check if the label already exists
await github.rest.issues.getLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: sizeLabel,
});
} catch (error) {
// If label doesn't exist, create it with the specified color
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: sizeLabel,
color: color || 'b0b0b0', // Default to gray if no color is found
});
}
}
- name: Comment on large PRs
if: ${{ contains(steps.size-label.outputs.sizeLabel, 'XL') || contains(steps.size-label.outputs.sizeLabel, 'XXL') }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: "This PR is too large and may need to be broken into smaller pieces."
});