99
1010jobs :
1111 auto-assign :
12- runs-on : [self-hosted, linux, x64, big]
12+ runs-on : ubuntu-latest
1313 steps :
1414 - name : Assign Copilot (or others) to new PRs
15- uses : actions/github-script@v7.1.0
15+ uses : actions/github-script@main
1616 with :
1717 github-token : ${{ secrets.GITHUB_TOKEN }}
1818 script : |
@@ -21,13 +21,20 @@ jobs:
2121 const assignees = [copilotUsername]; // Or: ["copilot","anotheruser"]
2222 const currentAssignees = context.payload.pull_request.assignees.map(u => u.login);
2323 if (!assignees.every(a => currentAssignees.includes(a))) {
24- await github.rest.issues.addAssignees({
25- owner: context.repo.owner,
26- repo: context.repo.repo,
27- issue_number: context.payload.pull_request.number,
28- assignees
29- });
30- console.log(`Assigned ${assignees.join(", ")} to PR #${context.payload.pull_request.number}`);
24+ console.log(`PR has assignees to add. Attempting to assign ${assignees.join(", ")}...`);
25+
26+ try {
27+ await github.rest.issues.addAssignees({
28+ owner: context.repo.owner,
29+ repo: context.repo.repo,
30+ issue_number: context.payload.pull_request.number,
31+ assignees
32+ });
33+ console.log(`✅ Assigned ${assignees.join(", ")} to PR #${context.payload.pull_request.number}`);
34+ } catch (error) {
35+ console.log(`⚠️ Failed to assign users: ${error.message}`);
36+ console.log("Note: This may be due to insufficient permissions or the user not being a collaborator.");
37+ }
3138 } else {
32- console.log(`Already assigned: ${assignees.join(", ")} on PR #${context.payload.pull_request.number}`);
33- }
39+ console.log(`ℹ️ Already assigned: ${assignees.join(", ")} on PR #${context.payload.pull_request.number}`);
40+ }
0 commit comments