fix: respect GITHUB_TOKEN env var before PAT_s

This commit is contained in:
Sreetam Das 2020-07-16 05:56:13 +05:30
parent 5aa24f1b8d
commit 2becbe595c

View File

@ -1,6 +1,6 @@
const retryer = async (fetcher, variables, retries = 0) => {
if (retries > 7) {
throw new Error("Maximum retries exceeded");
throw new Error("Maximum retries with PAT_{1...8} exceeded");
}
try {
console.log(`Trying PAT_${retries + 1}`);
@ -8,7 +8,9 @@ const retryer = async (fetcher, variables, retries = 0) => {
// try to fetch with the first token since RETRIES is 0 index i'm adding +1
let response = await fetcher(
variables,
process.env[`PAT_${retries + 1}`],
retries && typeof process.env["GITHUB_TOKEN"] === "undefined"
? process.env[`PAT_${retries + 1}`]
: process.env["GITHUB_TOKEN"],
retries
);