This commit is contained in:
Wathanyu Phromma
2020-05-29 20:37:00 +07:00
parent bc5ff62522
commit c2d9bb82a5
6 changed files with 61 additions and 19 deletions

View File

@@ -10,10 +10,6 @@ function sleep(ms: number) {
}
try {
process.on('uncaughtException', function (err) {
sleep(10000)
console.error(err.message)
})
if(core.getInput('custom-config')){
const configPath = core.getInput('custom-config');
const basePath = process.env.GITHUB_WORKSPACE;

View File

@@ -25,22 +25,27 @@ export const sendRequestWithRetry = (config: AxiosRequestConfig): void => {
const retryArr: string[] = core.getInput('retry').split('/')
const numberOfRetry: number = Number(retryArr[0])
const backoff: number = Number(retryArr[1])
core.info(`retry: ${countRetry}`)
do {
axios(config)
try{
axios(config)
.then(res => {
exit = true
setOutput(res)
})
.catch(err => {
countRetry += 1
core.info(`retry: ${countRetry}`)
if (countRetry <= numberOfRetry) {
sleep(backoff)
} else {
exit = true
core.setFailed(err)
}
throw new Error(err)
})
}catch(err){
countRetry += 1
core.info(`retry: ${countRetry}`)
if (countRetry <= numberOfRetry) {
sleep(backoff)
} else {
exit = true
core.setFailed(err)
}
}
} while (!exit)
}