Add logic to retry github uploads

When doing release, sometimes the GitHub upload fails, so try to retry it once before bailing.
This commit is contained in:
John Kleinschmidt 2017-10-04 10:33:27 -04:00
parent d7aa0b0ddb
commit 54563dc94c

View file

@ -13,9 +13,22 @@ let githubOpts = {
filePath: filePath,
name: fileName
}
github.repos.uploadAsset(githubOpts).then(() => {
process.exit()
}).catch((err) => {
console.log(`Error uploading ${fileName} to GitHub:`, err)
process.exitCode = 1
})
let retry = true
function uploadToGitHub () {
github.repos.uploadAsset(githubOpts).then(() => {
process.exit()
}).catch((err) => {
if (retry) {
console.log(`Error uploading ${fileName} to GitHub, will retry. Error was:`, err)
retry = false
uploadToGitHub()
} else {
console.log(`Error retrying uploading ${fileName} to GitHub:`, err)
process.exitCode = 1
}
})
}
uploadToGitHub()