Skip to content

Commit 8c80c88

Browse files
Make auto-assign pool configurable via repo variables
Agent-Logs-Url: https://github.com/dotnet/SqlClient/sessions/f7cc4b22-e560-46ff-bc90-898ef69a406a Co-authored-by: cheenamalhotra <13396919+cheenamalhotra@users.noreply.github.com>
1 parent 6d4594b commit 8c80c88

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

.github/workflows/auto-assign-pr.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,39 @@ jobs:
1818
permissions:
1919
issues: write
2020
pull-requests: read
21+
env:
22+
AUTO_ASSIGN_PR_POOL: ${{ vars.AUTO_ASSIGN_PR_POOL }}
23+
AUTO_ASSIGN_PR_SKIP: ${{ vars.AUTO_ASSIGN_PR_SKIP }}
2124

2225
steps:
2326
- name: Calculate Workload and Apply
2427
uses: actions/github-script@v7
2528
with:
2629
script: |
27-
// Keep the candidate pool centralized in one place so every PR uses the same ranking.
28-
const pool = ['cheenamalhotra', 'paulmedynski', 'priyankatiwari08', 'benrr101', 'mdaigle', 'apoorvdeshmukh'];
2930
const owner = context.repo.owner;
3031
const repo = context.repo.repo;
3132
const prNumber = context.issue.number;
3233
const author = context.payload.pull_request.user.login;
3334
const normalizeLogin = login => login.toLowerCase();
35+
const parseCsvLogins = value => (value ?? '')
36+
.split(',')
37+
.map(entry => entry.trim())
38+
.filter(entry => entry.length > 0);
39+
40+
// Fallback pool keeps behavior unchanged when no repo variable is configured.
41+
const defaultPool = ['cheenamalhotra', 'paulmedynski', 'priyankatiwari08', 'benrr101', 'mdaigle', 'apoorvdeshmukh'];
42+
const configuredPool = parseCsvLogins(process.env.AUTO_ASSIGN_PR_POOL);
43+
const rawPool = configuredPool.length > 0 ? configuredPool : defaultPool;
44+
const skipUsers = new Set(parseCsvLogins(process.env.AUTO_ASSIGN_PR_SKIP).map(normalizeLogin));
45+
const seenPoolUsers = new Set();
46+
const pool = [];
47+
for (const user of rawPool) {
48+
const lower = normalizeLogin(user);
49+
if (!seenPoolUsers.has(lower)) {
50+
seenPoolUsers.add(lower);
51+
pool.push(user);
52+
}
53+
}
3454
3555
let latestPr;
3656
try {
@@ -64,6 +84,7 @@ jobs:
6484
6585
const candidates = pool.filter(user =>
6686
normalizeLogin(user) !== normalizeLogin(author) &&
87+
!skipUsers.has(normalizeLogin(user)) &&
6788
!currentAssignees.some(a => normalizeLogin(a) === normalizeLogin(user))
6889
);
6990

0 commit comments

Comments
 (0)