Skip to content

Commit 52db4a3

Browse files
committed
Sync auto-assign-copilot.yml from .github repo
1 parent a49df55 commit 52db4a3

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Auto Assign Copilot to Issues
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
- labeled
8+
9+
jobs:
10+
auto-assign:
11+
runs-on: ubuntu-latest
12+
if: contains(github.event.issue.labels.*.name, 'copilot')
13+
steps:
14+
- name: Assign Copilot to new issues
15+
uses: actions/github-script@main
16+
with:
17+
github-token: ${{ secrets.GITHUB_TOKEN }}
18+
script: |
19+
const copilotUsername = "copilot";
20+
21+
// Check if issue is already assigned to copilot
22+
const currentAssignees = context.payload.issue.assignees.map(u => u.login);
23+
24+
if (!currentAssignees.includes(copilotUsername)) {
25+
console.log(`Issue has 'copilot' label. Assigning @${copilotUsername}...`);
26+
27+
try {
28+
await github.rest.issues.addAssignees({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
issue_number: context.issue.number,
32+
assignees: [copilotUsername]
33+
});
34+
console.log(`✅ Assigned @${copilotUsername} to issue #${context.issue.number}`);
35+
} catch (error) {
36+
console.log(`⚠️ Failed to assign Copilot: ${error.message}`);
37+
console.log("Note: You must have a Copilot seat assigned to your account/org for this to work.");
38+
}
39+
} else {
40+
console.log(`ℹ️ @${copilotUsername} is already assigned to issue #${context.issue.number}`);
41+
}

0 commit comments

Comments
 (0)