mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2024-11-22 03:41:00 -05:00
build actions
This commit is contained in:
parent
748170326f
commit
bd6ff9fa68
1 changed files with 18 additions and 10 deletions
28
dist/index.js
vendored
28
dist/index.js
vendored
|
@ -2597,7 +2597,7 @@ module.exports = function httpAdapter(config) {
|
|||
const core = __webpack_require__(470);
|
||||
const axios = __webpack_require__(53);
|
||||
|
||||
const auth = {}
|
||||
let auth = undefined
|
||||
let customHeaders = {}
|
||||
|
||||
if (!!core.getInput('customHeaders')) {
|
||||
|
@ -2610,32 +2610,40 @@ if (!!core.getInput('customHeaders')) {
|
|||
|
||||
const headers = { 'Content-Type': core.getInput('contentType') || 'application/json' }
|
||||
|
||||
if (!!core.getInput('username')) {
|
||||
auth.username = core.getInput('username');
|
||||
}
|
||||
if (!!core.getInput('username') || !!core.getInput('password')) {
|
||||
core.debug('Add BasicHTTP Auth config')
|
||||
|
||||
if (!!core.getInput('password')) {
|
||||
auth.password = core.getInput('password');
|
||||
auth = {
|
||||
username: core.getInput('username'),
|
||||
password: core.getInput('password')
|
||||
}
|
||||
}
|
||||
|
||||
if (!!core.getInput('bearerToken')) {
|
||||
headers['Authentication'] = `Bearer ${core.getInput('bearerToken')}`;
|
||||
}
|
||||
|
||||
const instance = axios.create({
|
||||
const instanceConfig = {
|
||||
baseURL: core.getInput('url', { required: true }),
|
||||
timeout: parseInt(core.getInput('timeout') || 5000, 10),
|
||||
headers: { ...headers, ...customHeaders }
|
||||
});
|
||||
}
|
||||
|
||||
core.debug(JSON.stringify(instanceConfig))
|
||||
|
||||
const instance = axios.create(instanceConfig);
|
||||
|
||||
(async() => {
|
||||
try {
|
||||
const response = await instance.request({
|
||||
const requestData = {
|
||||
auth,
|
||||
method: core.getInput('method') || 'POST',
|
||||
data: JSON.parse(core.getInput('data') || '{}')
|
||||
})
|
||||
}
|
||||
|
||||
core.debug(JSON.stringify(requestData))
|
||||
|
||||
const response = await instance.request(requestData)
|
||||
|
||||
core.setOutput('response', JSON.stringify(response.data))
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in a new issue