Compare commits

...

2 Commits
v1.0 ... v1.1.0

Author SHA1 Message Date
Frank
88637cb5c4 Update dist 2020-03-25 11:23:19 +01:00
Frank
0170dcbc31 Add support for custom headers 2020-03-25 11:15:19 +01:00
3 changed files with 23 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ jobs:
|username| Username for Basic Auth ||
|password| Password for Basic Auth ||
|bearerToken| Bearer Authentication Token (without Bearer Prefix) ||
|customHeaders| Additional header values as JSON string, keys in this object overwrite default headers like Content-Type |'{}'|
### Output

12
dist/index.js vendored
View File

@@ -2598,6 +2598,16 @@ const core = __webpack_require__(470);
const axios = __webpack_require__(53);
const auth = {}
let customHeaders = {}
if (!!core.getInput('customHeaders')) {
try {
customHeaders = JSON.parse(core.getInput('customHeaders'));
} catch(error) {
core.error('Could not parse customHeaders string value')
}
}
const headers = { 'Content-Type': core.getInput('contentType') || 'application/json' }
if (!!core.getInput('username')) {
@@ -2615,7 +2625,7 @@ if (!!core.getInput('bearerToken')) {
const instance = axios.create({
baseURL: core.getInput('url', { required: true }),
timeout: parseInt(core.getInput('timeout') || 5000, 10),
headers
headers: { ...headers, ...customHeaders }
});

View File

@@ -2,6 +2,16 @@ const core = require("@actions/core");
const axios = require("axios");
const auth = {}
let customHeaders = {}
if (!!core.getInput('customHeaders')) {
try {
customHeaders = JSON.parse(core.getInput('customHeaders'));
} catch(error) {
core.error('Could not parse customHeaders string value')
}
}
const headers = { 'Content-Type': core.getInput('contentType') || 'application/json' }
if (!!core.getInput('username')) {
@@ -19,7 +29,7 @@ if (!!core.getInput('bearerToken')) {
const instance = axios.create({
baseURL: core.getInput('url', { required: true }),
timeout: parseInt(core.getInput('timeout') || 5000, 10),
headers
headers: { ...headers, ...customHeaders }
});