Skip to content

Commit 8552a1e

Browse files
committed
Auto Assign - Update the lookup for a valid user id. (#2559)
1 parent 072f768 commit 8552a1e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

.github/workflows/copilot-triage-assignment.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- name: Check if actor is authorized
2323
id: check_auth
24-
uses: actions/github-script@v6
24+
uses: actions/github-script@v7
2525
with:
2626
github-token: ${{ secrets.GITHUB_TOKEN }}
2727
script: |
@@ -65,7 +65,7 @@ jobs:
6565

6666
- name: Assign GitHub Copilot
6767
if: ${{ steps.check_auth.outputs.result == 'true' }}
68-
uses: actions/github-script@v6
68+
uses: actions/github-script@v7
6969
with:
7070
github-token: ${{ secrets.GITHUB_TOKEN }}
7171
script: |
@@ -81,14 +81,18 @@ jobs:
8181
for (const username of possibleCopilotUsers) {
8282
try {
8383
// Check if user exists and can be assigned
84-
const userCheck = await github.rest.users.getByUsername({
84+
const user = await github.rest.users.getByUsername({
8585
username: username
8686
});
8787
88-
if (userCheck.status === 200) {
88+
if (user.data && user.data.login === username && user.data.type === "Bot") {
8989
assigneeUsername = username;
9090
console.log(`Found valid assignee: ${username}`);
9191
break;
92+
} else if (user){
93+
console.log(`User ${username} is not a valid assignee - ${user.status}`);
94+
} else {
95+
console.log(`API Call failed for ${username} - ${user}`);
9296
}
9397
} catch (userError) {
9498
console.log(`User ${username} not found or not available: ${userError.message}`);
@@ -104,6 +108,8 @@ jobs:
104108
issue_number: issueOrPR.number,
105109
assignees: [assigneeUsername]
106110
});
111+
112+
console.log(`AssignResult: ${assignResult.status}`);
107113
108114
// Verify assignment was successful by checking the response
109115
if (assignResult.status === 201 && assignResult.data.assignees.some(a => a.login === assigneeUsername)) {
@@ -139,8 +145,7 @@ jobs:
139145
repo: context.repo.repo,
140146
issue_number: issueOrPR.number,
141147
body: '**Action Required**: Unable to directly assign GitHub Copilot to this task.\n\n' +
142-
'This issue has been labeled with `needs-copilot-attention` for review by the team.\n\n' +
143-
'To request GitHub Copilot assistance, please notify an administrator.'
148+
'This issue has been labeled with `needs-copilot-attention` for review by the team.'
144149
});
145150
146151
console.log(`Added 'needs-copilot-attention' label to ${context.repo.owner}/${context.repo.repo}#${issueOrPR.number}`); } catch (error) {

0 commit comments

Comments
 (0)