Skip to content

Commit 54563dc

Browse files
author
John Kleinschmidt
committed
Add logic to retry github uploads
When doing release, sometimes the GitHub upload fails, so try to retry it once before bailing.
1 parent d7aa0b0 commit 54563dc

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

script/upload-to-github.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,22 @@ let githubOpts = {
1313
filePath: filePath,
1414
name: fileName
1515
}
16-
github.repos.uploadAsset(githubOpts).then(() => {
17-
process.exit()
18-
}).catch((err) => {
19-
console.log(`Error uploading ${fileName} to GitHub:`, err)
20-
process.exitCode = 1
21-
})
16+
17+
let retry = true
18+
19+
function uploadToGitHub () {
20+
github.repos.uploadAsset(githubOpts).then(() => {
21+
process.exit()
22+
}).catch((err) => {
23+
if (retry) {
24+
console.log(`Error uploading ${fileName} to GitHub, will retry. Error was:`, err)
25+
retry = false
26+
uploadToGitHub()
27+
} else {
28+
console.log(`Error retrying uploading ${fileName} to GitHub:`, err)
29+
process.exitCode = 1
30+
}
31+
})
32+
}
33+
34+
uploadToGitHub()

0 commit comments

Comments
 (0)