Merge pull request #10688 from electron/retry-uploads
Add logic to retry github uploads
This commit is contained in:
		
				commit
				
					
						30abdbccf8
					
				
			
		
					 1 changed files with 24 additions and 6 deletions
				
			
		|  | @ -2,6 +2,10 @@ const GitHub = require('github') | |||
| const github = new GitHub() | ||||
| github.authenticate({type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN}) | ||||
| 
 | ||||
| if (process.argv.length < 5) { | ||||
|   console.log('Usage: upload-to-github filePath fileName releaseId') | ||||
|   process.exit(1) | ||||
| } | ||||
| let filePath = process.argv[2] | ||||
| let fileName = process.argv[3] | ||||
| let releaseId = process.argv[4] | ||||
|  | @ -13,9 +17,23 @@ 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 = 0 | ||||
| 
 | ||||
| function uploadToGitHub () { | ||||
|   github.repos.uploadAsset(githubOpts).then(() => { | ||||
|     console.log(`Successfully uploaded ${fileName} to GitHub.`) | ||||
|     process.exit() | ||||
|   }).catch((err) => { | ||||
|     if (retry < 4) { | ||||
|       console.log(`Error uploading ${fileName} to GitHub, will retry.  Error was:`, err) | ||||
|       retry++ | ||||
|       uploadToGitHub() | ||||
|     } else { | ||||
|       console.log(`Error retrying uploading ${fileName} to GitHub:`, err) | ||||
|       process.exitCode = 1 | ||||
|     } | ||||
|   }) | ||||
| } | ||||
| 
 | ||||
| uploadToGitHub() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 John Kleinschmidt
				John Kleinschmidt