Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/auto-assign-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Auto Assign Copilot (or any username) to every new pull request.
# Tweak the username(s) below as needed!

name: Auto Assign Copilot to PRs

on:
pull_request:
types: [opened]

jobs:
auto-assign:
runs-on: ubuntu-latest
steps:
- name: Assign Copilot (or others) to new PRs
uses: actions/github-script@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Assign PRs to Copilot or other users
const copilotUsername = "copilot"; // <-- TUNE ME!
const assignees = [copilotUsername]; // Or: ["copilot","anotheruser"]
const currentAssignees = context.payload.pull_request.assignees.map(u => u.login);
if (!assignees.every(a => currentAssignees.includes(a))) {
console.log(`PR has assignees to add. Attempting to assign ${assignees.join(", ")}...`);

try {
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
assignees
});
console.log(`✅ Assigned ${assignees.join(", ")} to PR #${context.payload.pull_request.number}`);

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
Comment on lines +12 to +33
} catch (error) {
console.log(`⚠️ Failed to assign users: ${error.message}`);
console.log("Note: This may be due to insufficient permissions or the user not being a collaborator.");
}
} else {
console.log(`ℹ️ Already assigned: ${assignees.join(", ")} on PR #${context.payload.pull_request.number}`);
}
Loading
Loading