From c609479376c92be2991c6d072a70201f7e225047 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 18 Jan 2022 11:01:07 -0800 Subject: [PATCH] Fix crash when org check is empty, run once weekly (#58281) --- .github/workflows/ghostbuster.yml | 4 ++-- scripts/ghostbuster.cjs | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ghostbuster.yml b/.github/workflows/ghostbuster.yml index c38e318be9..314371b47e 100644 --- a/.github/workflows/ghostbuster.yml +++ b/.github/workflows/ghostbuster.yml @@ -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: diff --git a/scripts/ghostbuster.cjs b/scripts/ghostbuster.cjs index e29b5e072a..cca6ad1bbb 100644 --- a/scripts/ghostbuster.cjs +++ b/scripts/ghostbuster.cjs @@ -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); } /**