add retry feature

This commit is contained in:
Wathanyu Phromma
2020-05-29 19:21:50 +07:00
parent 9f85844a4a
commit 7bcf97e139
3 changed files with 37 additions and 7 deletions

View File

@@ -1,11 +1,9 @@
import axios from 'axios'
import axios, { AxiosRequestConfig } from 'axios'
import config from './requestconf'
import * as core from '@actions/core'
import { AxiosRequestConfig } from 'axios'
import setOutput from './output'
import * as fs from 'fs'
import { sendRequestWithRetry } from './util'
try {
if(core.getInput('custom-config')){
@@ -20,10 +18,11 @@ try {
throw new Error('Config file not found, meybe you need to use action/checkout before this step or there is typo on file name')
}
let customConfig: AxiosRequestConfig = JSON.parse(fs.readFileSync(path).toString()) as AxiosRequestConfig;
axios(customConfig).then(res => setOutput(res)).catch(err => core.setFailed(err.message))
sendRequestWithRetry(customConfig)
}else{
axios(config).then(res => setOutput(res)).catch(err => core.setFailed(err.message))
sendRequestWithRetry(config)
}
} catch (err) {
core.setFailed(err.message);
}