Skip to content

Commit cf10f40

Browse files
authored
feat(ci): auto-label issues with GPT-5 mini (#1998)
1 parent 84f1f78 commit cf10f40

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

.github/workflows/auto-label-issues.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ jobs:
1515
concurrency:
1616
group: auto-label
1717
cancel-in-progress: false
18-
# Only run if issue doesn't have a T- label
19-
if: "!contains(join(github.event.issue.labels.*.name, ','), 'T-')"
2018

2119
steps:
2220
- name: Check user account age to prevent spam
@@ -69,6 +67,8 @@ jobs:
6967
const issueTitle = context.payload.issue.title;
7068
const issueBody = context.payload.issue.body || '';
7169
const issueNumber = context.payload.issue.number;
70+
const existingLabels = context.payload.issue.labels.map(l => l.name);
71+
const existingLabelsStr = existingLabels.join(', ') || 'none';
7272
7373
// Truncate very long issue bodies to prevent abuse
7474
const maxBodyLength = 8000;
@@ -86,6 +86,7 @@ jobs:
8686
<issue_content>
8787
Issue #${issueNumber}
8888
Title: ${issueTitle}
89+
Current labels: ${existingLabelsStr}
8990
9091
Body:
9192
${truncatedBody}
@@ -149,7 +150,7 @@ jobs:
149150
// Call OpenAI GPT-5 mini API
150151
const requestBody = JSON.stringify({
151152
model: 'gpt-5-mini',
152-
max_tokens: 1024,
153+
max_completion_tokens: 1024,
153154
response_format: { type: "json_object" },
154155
messages: [{
155156
role: 'system',
@@ -224,6 +225,21 @@ jobs:
224225
225226
// Apply labels
226227
if (labelsToApply.length > 0) {
228+
// Remove existing labels
229+
for (const label of existingLabels) {
230+
try {
231+
await github.rest.issues.removeLabel({
232+
owner: context.repo.owner,
233+
repo: context.repo.repo,
234+
issue_number: issueNumber,
235+
name: label
236+
});
237+
} catch (e) {
238+
console.log(`Could not remove label ${label}:`, e.message);
239+
}
240+
}
241+
242+
// Add new labels
227243
await github.rest.issues.addLabels({
228244
owner: context.repo.owner,
229245
repo: context.repo.repo,
@@ -240,17 +256,16 @@ jobs:
240256
owner: context.repo.owner,
241257
repo: context.repo.repo,
242258
issue_number: issueNumber,
243-
body: `🤖 **Auto-labeled by GPT-5**
259+
body: `🤖 **Auto-labeled**
244260
245261
Applied labels:
246262
${confidenceList}
247263
248264
**Reasoning:** ${analysis.reasoning}
249265
250-
If these labels are incorrect, please update them. This helps improve the auto-labeling system.
266+
Previous labels: \`${existingLabelsStr}\`
251267
252-
---
253-
<sub>Powered by [GPT-5 mini](https://openai.com/index/introducing-gpt-5-for-developers/) | [Workflow](https://github.com/${context.repo.owner}/${context.repo.repo}/blob/main/.github/workflows/auto-label-issues.yml)</sub>`
268+
If these labels are incorrect, please update them. This helps improve the auto-labeling system.`
254269
});
255270
256271
console.log('Successfully applied labels and posted comment');

0 commit comments

Comments
 (0)