Skip to content

Commit 5a64056

Browse files
authored
Add cron schedule for 8 am CT & 1 pm CT, and exclude dependabot & tgonzalezorlandoarm (pytorch#16375)
1 parent 9a30bd3 commit 5a64056

1 file changed

Lines changed: 36 additions & 13 deletions

File tree

‎.github/workflows/add-unanswered-to-project.yml‎

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ name: Add Open External Contributor PRs and Issues to PyTorch Org Project 136
22

33
on:
44
workflow_dispatch:
5-
pull_request:
6-
paths:
7-
.github/workflows/add-unanswered-to-project.yml
5+
schedule:
6+
# GitHub Actions cron uses UTC. These run at:
7+
# - 14:00 UTC -> 08:00 CST (UTC-6)
8+
# - 19:00 UTC -> 13:00 CST (UTC-6)
9+
- cron: "0 14 * * *"
10+
- cron: "0 19 * * *"
11+
pull_request:
12+
paths:
13+
- .github/workflows/add-unanswered-to-project.yml
814
jobs:
915
add_to_project:
1016
runs-on: ubuntu-latest
1117
steps:
12-
- name: Add open issues and open, non-draft PRs to org project (excluding certain authors)
18+
- name: Add open issues and open, non-draft PRs to org project (excluding certain authors and bots)
1319
uses: actions/github-script@v7
1420
with:
1521
github-token: ${{ secrets.ET_EXT_CONTRIB }}
@@ -41,13 +47,26 @@ jobs:
4147
"app/dependabot", "Erik-Lundell", "zingo", "AdrianLundell", "oscarandersson8218", "per", "Sebastian-Larsson", "SaoirseARM",
4248
"robell", "mansnils", "martinlsm", "freddan80", "YufengShi-dudu", "tom-arm", "perheld", "Jerry-Ge", "gggekov", "fumchin",
4349
"wwwind", "benkli01", "Tessil", "maddun01", "Michiel-Olieslagers", "armwaheed", "agrima1304", "emmakujala", "annietllnd",
44-
"MatthiasHertel80", "AlexTawseArm", "jmahbs", "morgolock", "Christoffer-JL", "ArmRyan", "xingguo01", "haowhsu-quic",
45-
"shewu-quic", "winskuo-quic", "chunit-quic", "DannyYuyang-quic", "chuntl", "thchenqti", "jethroqti", "chenweng-quic",
46-
"cymbalrush", "DenisVieriu97", "billmguo", "StrycekSimon", "jirioc", "robert-kalmar", "skywall", "MartinPavella",
47-
"roman-janik-nxp", "novak-vaclav ", "neuropilot-captain", "dijopaul", "cad-rlc", "cad-audio", "ynimmaga", "daniil-lyakhov",
48-
"emmanuel-ferdman", "cavusmustafa", "anzr299", "Jiseong-oh", "alexdean08"
50+
"MatthiasHertel80", "AlexTawseArm", "jmahbs", "morgolock", "Christoffer-JL", "ArmRyan", "xingguo01", "tgonzalezorlandoarm",
51+
"haowhsu-quic", "shewu-quic", "winskuo-quic", "chunit-quic", "DannyYuyang-quic", "chuntl", "thchenqti", "jethroqti",
52+
"chenweng-quic", "cymbalrush", "DenisVieriu97", "billmguo", "StrycekSimon", "jirioc", "robert-kalmar", "skywall",
53+
"MartinPavella", "roman-janik-nxp", "novak-vaclav", "neuropilot-captain", "dijopaul", "cad-rlc", "cad-audio", "ynimmaga",
54+
"daniil-lyakhov", "emmanuel-ferdman", "cavusmustafa", "anzr299", "Jiseong-oh", "alexdean08",
55+
// explicitly include the dependabot bot login seen in PRs
56+
"dependabot[bot]"
4957
]);
5058
59+
function isBotOrExcluded(user) {
60+
if (!user) return false;
61+
// GitHub sometimes marks bots with user.type === "Bot"
62+
if (user.type && user.type.toLowerCase() === "bot") return true;
63+
// Some bots use logins that end with [bot], e.g. dependabot[bot]
64+
if (user.login && user.login.endsWith("[bot]")) return true;
65+
// Explicit excluded list
66+
if (excludedAuthors.has(user.login)) return true;
67+
return false;
68+
}
69+
5170
async function addItem(contentId, type, number) {
5271
try {
5372
await github.graphql(`
@@ -69,7 +88,7 @@ jobs:
6988
}
7089
7190
try {
72-
// Add open issues (not PRs) and exclude by author
91+
// Add open issues (not PRs) and exclude by author/bots
7392
const issues = await github.paginate(
7493
github.rest.issues.listForRepo,
7594
{
@@ -80,12 +99,14 @@ jobs:
8099
}
81100
);
82101
for (const issue of issues) {
83-
if (!issue.pull_request && !excludedAuthors.has(issue.user.login)) {
102+
if (!issue.pull_request && !isBotOrExcluded(issue.user)) {
84103
await addItem(issue.node_id, 'issue', issue.number);
104+
} else {
105+
console.log(`Skipping issue #${issue.number} by ${issue.user && issue.user.login}`);
85106
}
86107
}
87108
88-
// Add open, non-draft PRs (regardless of review state), exclude by author
109+
// Add open, non-draft PRs (regardless of review state), exclude by author/bots
89110
const prs = await github.paginate(
90111
github.rest.pulls.list,
91112
{
@@ -95,8 +116,10 @@ jobs:
95116
}
96117
);
97118
for (const pr of prs) {
98-
if (!pr.draft && !excludedAuthors.has(pr.user.login)) {
119+
if (!pr.draft && !isBotOrExcluded(pr.user)) {
99120
await addItem(pr.node_id, 'pr', pr.number);
121+
} else {
122+
console.log(`Skipping PR #${pr.number} by ${pr.user && pr.user.login}`);
100123
}
101124
}
102125
} catch (error) {

0 commit comments

Comments
 (0)