Skip to content
Open
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
49 changes: 36 additions & 13 deletions .github/workflows/add-unanswered-to-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ name: Add Open External Contributor PRs and Issues to PyTorch Org Project 136

on:
workflow_dispatch:
pull_request:
paths:
.github/workflows/add-unanswered-to-project.yml
schedule:
# GitHub Actions cron uses UTC. These run at:
# - 14:00 UTC -> 08:00 CST (UTC-6)
# - 19:00 UTC -> 13:00 CST (UTC-6)
- cron: "0 14 * * *"
- cron: "0 19 * * *"
pull_request:
paths:
- .github/workflows/add-unanswered-to-project.yml
jobs:
add_to_project:
runs-on: ubuntu-latest
steps:
- name: Add open issues and open, non-draft PRs to org project (excluding certain authors)
- name: Add open issues and open, non-draft PRs to org project (excluding certain authors and bots)
uses: actions/github-script@v7
with:
github-token: ${{ secrets.ET_EXT_CONTRIB }}
Expand Down Expand Up @@ -41,13 +47,26 @@ jobs:
"app/dependabot", "Erik-Lundell", "zingo", "AdrianLundell", "oscarandersson8218", "per", "Sebastian-Larsson", "SaoirseARM",
"robell", "mansnils", "martinlsm", "freddan80", "YufengShi-dudu", "tom-arm", "perheld", "Jerry-Ge", "gggekov", "fumchin",
"wwwind", "benkli01", "Tessil", "maddun01", "Michiel-Olieslagers", "armwaheed", "agrima1304", "emmakujala", "annietllnd",
"MatthiasHertel80", "AlexTawseArm", "jmahbs", "morgolock", "Christoffer-JL", "ArmRyan", "xingguo01", "haowhsu-quic",
"shewu-quic", "winskuo-quic", "chunit-quic", "DannyYuyang-quic", "chuntl", "thchenqti", "jethroqti", "chenweng-quic",
"cymbalrush", "DenisVieriu97", "billmguo", "StrycekSimon", "jirioc", "robert-kalmar", "skywall", "MartinPavella",
"roman-janik-nxp", "novak-vaclav ", "neuropilot-captain", "dijopaul", "cad-rlc", "cad-audio", "ynimmaga", "daniil-lyakhov",
"emmanuel-ferdman", "cavusmustafa", "anzr299", "Jiseong-oh", "alexdean08"
"MatthiasHertel80", "AlexTawseArm", "jmahbs", "morgolock", "Christoffer-JL", "ArmRyan", "xingguo01", "tgonzalezorlandoarm",
"haowhsu-quic", "shewu-quic", "winskuo-quic", "chunit-quic", "DannyYuyang-quic", "chuntl", "thchenqti", "jethroqti",
"chenweng-quic", "cymbalrush", "DenisVieriu97", "billmguo", "StrycekSimon", "jirioc", "robert-kalmar", "skywall",
"MartinPavella", "roman-janik-nxp", "novak-vaclav", "neuropilot-captain", "dijopaul", "cad-rlc", "cad-audio", "ynimmaga",
"daniil-lyakhov", "emmanuel-ferdman", "cavusmustafa", "anzr299", "Jiseong-oh", "alexdean08",
// explicitly include the dependabot bot login seen in PRs
"dependabot[bot]"
]);

function isBotOrExcluded(user) {
if (!user) return false;
// GitHub sometimes marks bots with user.type === "Bot"
if (user.type && user.type.toLowerCase() === "bot") return true;
// Some bots use logins that end with [bot], e.g. dependabot[bot]
if (user.login && user.login.endsWith("[bot]")) return true;
// Explicit excluded list
if (excludedAuthors.has(user.login)) return true;
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function checks user.login on line 66 without first verifying that user.login exists. While line 60 checks if user is truthy, if user exists but user.login is null/undefined, this could cause issues. Consider adding a check like "if (user.login && excludedAuthors.has(user.login))" for consistency with the bot login check on line 64.

Suggested change
if (excludedAuthors.has(user.login)) return true;
if (user.login && excludedAuthors.has(user.login)) return true;

Copilot uses AI. Check for mistakes.
return false;
}

async function addItem(contentId, type, number) {
try {
await github.graphql(`
Expand All @@ -69,7 +88,7 @@ jobs:
}

try {
// Add open issues (not PRs) and exclude by author
// Add open issues (not PRs) and exclude by author/bots
const issues = await github.paginate(
github.rest.issues.listForRepo,
{
Expand All @@ -80,12 +99,14 @@ jobs:
}
);
for (const issue of issues) {
if (!issue.pull_request && !excludedAuthors.has(issue.user.login)) {
if (!issue.pull_request && !isBotOrExcluded(issue.user)) {
await addItem(issue.node_id, 'issue', issue.number);
} else {
console.log(`Skipping issue #${issue.number} by ${issue.user && issue.user.login}`);
}
}

// Add open, non-draft PRs (regardless of review state), exclude by author
// Add open, non-draft PRs (regardless of review state), exclude by author/bots
const prs = await github.paginate(
github.rest.pulls.list,
{
Expand All @@ -95,8 +116,10 @@ jobs:
}
);
for (const pr of prs) {
if (!pr.draft && !excludedAuthors.has(pr.user.login)) {
if (!pr.draft && !isBotOrExcluded(pr.user)) {
await addItem(pr.node_id, 'pr', pr.number);
} else {
console.log(`Skipping PR #${pr.number} by ${pr.user && pr.user.login}`);
}
}
} catch (error) {
Expand Down
Loading