Fix crash when org check is empty, run once weekly (#58281)

This commit is contained in:
Andrew Branch
2022-01-18 11:01:07 -08:00
committed by GitHub
parent fad9862b5e
commit c609479376
2 changed files with 13 additions and 7 deletions

View File

@@ -2,8 +2,8 @@ name: Remove contributors with deleted accounts
on:
schedule:
# https://crontab.guru/#0_0_*_*_*
- cron: "0 0 * * *"
# https://crontab.guru/#0_0_*_*_1
- cron: "0 0 * * 1"
workflow_dispatch:
inputs:
skipPR:

View File

@@ -103,11 +103,17 @@ async function fetchGhosts(users) {
}
// Filter out organizations
const query = `query {
${ghosts.map((user, i) => `o${i}: organization(login: "${user}") { id }`).join("\n")}
}`;
const result = await tryGQL(() => octokit.graphql(query));
return new Set(ghosts.filter(g => result.data[`o${ghosts.indexOf(g)}`] === null));
if (ghosts.length) {
const query = `query {
${ghosts.map((user, i) => `o${i}: organization(login: "${user}") { id }`).join("\n")}
}`;
const result = await tryGQL(() => octokit.graphql(query));
if (result.data) {
return new Set(ghosts.filter(g => result.data[`o${ghosts.indexOf(g)}`] === null));
}
}
return new Set(ghosts);
}
/**