The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 07:30 UTC
fix pr size workflow
Julius Marminge committed
Mar 12, 2026 at 12:01 UTC
d9d0216e98062bb69c0b3f7cb67cd9a3c5742216
1 file changed
+80
-38
.github/workflows/pr-size.yml
+80
-38
@@ -3,29 +3,29 @@ name: PR Size
3
on:
4
pull_request_target:
5
types: [opened, reopened, synchronize, ready_for_review, converted_to_draft]
6
+ workflow_dispatch:
7
+ push:
8
+ branches:
9
+ - main
10
+ paths:
11
+ - .github/workflows/pr-size.yml
12
13
permissions:
14
contents: read
9
- issues: write
10
- pull-requests: read
15
16
jobs:
13
- label:
14
- name: Label PR size
17
+ prepare-config:
18
+ name: Prepare PR size config
19
runs-on: ubuntu-24.04
16
- concurrency:
17
- group: pr-size-${{ github.event.pull_request.number }}
18
- cancel-in-progress: true
20
+ outputs:
21
+ labels_json: ${{ steps.config.outputs.labels_json }}
22
steps:
20
- - name: Sync PR size label
23
+ - id: config
24
+ name: Build PR size label config
25
uses: actions/github-script@v7
26
with:
27
+ result-encoding: string
28
script: |
24
- const issueNumber = context.payload.pull_request.number;
25
- const additions = context.payload.pull_request.additions ?? 0;
26
- const deletions = context.payload.pull_request.deletions ?? 0;
27
- const changedLines = additions + deletions;
28
-
29
const managedLabels = [
30
{
31
name: "size:XS",
@@ -59,31 +59,23 @@ jobs:
59
},
60
];
61
62
- const managedLabelNames = new Set(managedLabels.map((label) => label.name));
63
-
64
- const resolveSizeLabel = (totalChangedLines) => {
65
- if (totalChangedLines < 10) {
66
- return "size:XS";
67
- }
68
-
69
- if (totalChangedLines < 30) {
70
- return "size:S";
71
- }
72
-
73
- if (totalChangedLines < 100) {
74
- return "size:M";
75
- }
76
-
77
- if (totalChangedLines < 500) {
78
- return "size:L";
79
- }
80
-
81
- if (totalChangedLines < 1000) {
82
- return "size:XL";
83
- }
84
-
85
- return "size:XXL";
86
- };
62
+ core.setOutput("labels_json", JSON.stringify(managedLabels));
63
+ sync-label-definitions:
64
+ name: Sync PR size label definitions
65
+ needs: prepare-config
66
+ if: github.event_name != 'pull_request_target'
67
+ runs-on: ubuntu-24.04
68
+ permissions:
69
+ contents: read
70
+ issues: write
71
+ steps:
72
+ - name: Ensure PR size labels exist
73
+ uses: actions/github-script@v7
74
+ env:
75
+ PR_SIZE_LABELS_JSON: ${{ needs.prepare-config.outputs.labels_json }}
76
+ with:
77
+ script: |
78
+ const managedLabels = JSON.parse(process.env.PR_SIZE_LABELS_JSON ?? "[]");
79
80
for (const label of managedLabels) {
81
try {
@@ -125,6 +117,56 @@ jobs:
117
}
118
}
119
}
120
+ label:
121
+ name: Label PR size
122
+ needs: prepare-config
123
+ if: github.event_name == 'pull_request_target'
124
+ runs-on: ubuntu-24.04
125
+ permissions:
126
+ contents: read
127
+ issues: read
128
+ pull-requests: write
129
+ concurrency:
130
+ group: pr-size-${{ github.event.pull_request.number }}
131
+ cancel-in-progress: true
132
+ steps:
133
+ - name: Sync PR size label
134
+ uses: actions/github-script@v7
135
+ env:
136
+ PR_SIZE_LABELS_JSON: ${{ needs.prepare-config.outputs.labels_json }}
137
+ with:
138
+ script: |
139
+ const issueNumber = context.payload.pull_request.number;
140
+ const additions = context.payload.pull_request.additions ?? 0;
141
+ const deletions = context.payload.pull_request.deletions ?? 0;
142
+ const changedLines = additions + deletions;
143
+ const managedLabels = JSON.parse(process.env.PR_SIZE_LABELS_JSON ?? "[]");
144
+
145
+ const managedLabelNames = new Set(managedLabels.map((label) => label.name));
146
+
147
+ const resolveSizeLabel = (totalChangedLines) => {
148
+ if (totalChangedLines < 10) {
149
+ return "size:XS";
150
+ }
151
+
152
+ if (totalChangedLines < 30) {
153
+ return "size:S";
154
+ }
155
+
156
+ if (totalChangedLines < 100) {
157
+ return "size:M";
158
+ }
159
+
160
+ if (totalChangedLines < 500) {
161
+ return "size:L";
162
+ }
163
+
164
+ if (totalChangedLines < 1000) {
165
+ return "size:XL";
166
+ }
167
+
168
+ return "size:XXL";
169
+ };
170
171
const nextLabelName = resolveSizeLabel(changedLines);
172