Skip to content

Commit a355b0f

Browse files
committed
Sync auto-assign-copilot.yml from .github repo
1 parent 185a100 commit a355b0f

File tree

1 file changed

+46
-60
lines changed

1 file changed

+46
-60
lines changed
Lines changed: 46 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,58 @@
1-
name: Auto Assign Copilot to Issues
1+
name: Copilot on label
22

33
on:
4-
54
issues:
5+
types: [labeled]
66

7-
types:
8-
9-
- opened
10-
11-
- labeled
7+
permissions:
8+
issues: write
129

1310
jobs:
14-
15-
auto-assign:
16-
17-
runs-on: self-hosted
18-
19-
if: contains(github.event.issue.labels.*.name, 'copilot')
20-
11+
copilot:
12+
# only run when the label that was added is exactly "copilot"
13+
if: github.event.label.name == 'copilot'
14+
runs-on: ubuntu-latest
2115
steps:
22-
23-
- name: Assign Copilot to new issues
24-
25-
uses: actions/github-script@main
26-
16+
- name: Comment and (optionally) add model label
17+
uses: actions/github-script@v7
2718
with:
28-
2919
github-token: ${{ secrets.GITHUB_TOKEN }}
30-
3120
script: |
32-
33-
const copilotUsername = "copilot";
34-
35-
// Check if issue is already assigned to copilot
36-
37-
const currentAssignees = context.payload.issue.assignees.map(u => u.login);
38-
39-
if (!currentAssignees.includes(copilotUsername)) {
40-
41-
console.log(`Issue has 'copilot' label. Assigning @${copilotUsername}...`);
42-
43-
try {
44-
45-
await github.rest.issues.addAssignees({
46-
47-
owner: context.repo.owner,
48-
49-
repo: context.repo.repo,
50-
51-
issue_number: context.issue.number,
52-
53-
assignees: [copilotUsername]
54-
55-
});
56-
57-
console.log(`✅ Assigned @${copilotUsername} to issue #${context.issue.number}`);
58-
59-
} catch (error) {
60-
61-
console.log(`⚠️ Failed to assign Copilot: ${error.message}`);
62-
63-
console.log("Note: You must have a Copilot seat assigned to your account/org for this to work.");
64-
65-
}
66-
67-
} else {
68-
69-
console.log(`ℹ️ @${copilotUsername} is already assigned to issue #${context.issue.number}`);
70-
21+
const owner = context.repo.owner;
22+
const repo = context.repo.repo;
23+
const issue_number = context.issue.number;
24+
25+
// 1) Comment to summon Copilot
26+
await github.rest.issues.createComment({
27+
owner,
28+
repo,
29+
issue_number,
30+
body: '@copilot :)'
31+
});
32+
33+
// 2) Optional: add a model-selection label (only if you want this behavior)
34+
const modelLabel = 'copilot-gpt-5.3';
35+
36+
// Try to create the label (ignore if it already exists)
37+
try {
38+
await github.rest.issues.createLabel({
39+
owner,
40+
repo,
41+
name: modelLabel,
42+
color: '5319E7',
43+
description: 'Prefer GPT-5.3 for Copilot (if supported)'
44+
});
45+
} catch (e) {
46+
// 422 = already exists (or validation). We can safely ignore.
7147
}
7248
49+
// Add the label to the issue if it isn't already present
50+
const existing = new Set(context.payload.issue.labels.map(l => l.name));
51+
if (!existing.has(modelLabel)) {
52+
await github.rest.issues.addLabels({
53+
owner,
54+
repo,
55+
issue_number,
56+
labels: [modelLabel]
57+
});
58+
}

0 commit comments

Comments
 (0)