mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2026-02-04 16:45:52 +08:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dea4657059 | ||
|
|
ae65a272d9 | ||
|
|
6cbe966de9 | ||
|
|
1e440b8b8c | ||
|
|
7d4a18ad25 | ||
|
|
ed8a1c36db | ||
|
|
8af2803109 | ||
|
|
8537e58734 | ||
|
|
74e0e96181 | ||
|
|
2bb8059d00 | ||
|
|
bfbe4dd6af | ||
|
|
7c708e96af | ||
|
|
f9dc1a8d4b | ||
|
|
33a4d079d7 | ||
|
|
0b6ec5eadd | ||
|
|
897b6a3c96 | ||
|
|
363da44e0a | ||
|
|
1a131d17cc | ||
|
|
72a0a5b93e | ||
|
|
606bb16fb9 | ||
|
|
517601f732 | ||
|
|
c9a231b621 | ||
|
|
2e6550f5bd | ||
|
|
caab55e3d8 | ||
|
|
997aeb8de8 | ||
|
|
0bd00a33db | ||
|
|
a665541d9c | ||
|
|
e23645bd9b | ||
|
|
897543ff26 |
@@ -45,9 +45,10 @@ jobs:
|
|||||||
|httpsCert| Client Certificate as string ||
|
|httpsCert| Client Certificate as string ||
|
||||||
|httpsKey| Client Certificate Key as string ||
|
|httpsKey| Client Certificate Key as string ||
|
||||||
|responseFile| Persist the response data to the specified file path ||
|
|responseFile| Persist the response data to the specified file path ||
|
||||||
|markResponse| If set to true, the response will be masked in the logs of the action |'false'|
|
|maskResponse| If set to true, the response will be masked in the logs of the action |'false'|
|
||||||
|retry| optional amount of retries if the request is failing, does not retry if the status code is ignored ||
|
|retry| optional amount of retries if the request is failing, does not retry if the status code is ignored ||
|
||||||
|retryWait| time between each retry in millseconds | 3000 |
|
|retryWait| time between each retry in millseconds | 3000 |
|
||||||
|
|ignoreSsl| ignore ssl verify (rejectUnauthorized: false) | false |
|
||||||
|
|
||||||
### Response
|
### Response
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ jobs:
|
|||||||
|---|---|
|
|---|---|
|
||||||
`response` | Response as JSON String
|
`response` | Response as JSON String
|
||||||
`headers` | Headers
|
`headers` | Headers
|
||||||
|
`status` | HTTP status message
|
||||||
|
|
||||||
To display HTTP response data in the GitHub Actions log give the request an `id` and access its `outputs`. You can also access specific field from the response data using [fromJson()](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson) expression.
|
To display HTTP response data in the GitHub Actions log give the request an `id` and access its `outputs`. You can also access specific field from the response data using [fromJson()](https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson) expression.
|
||||||
|
|
||||||
@@ -69,6 +71,7 @@ steps:
|
|||||||
run: |
|
run: |
|
||||||
echo ${{ steps.myRequest.outputs.response }}
|
echo ${{ steps.myRequest.outputs.response }}
|
||||||
echo ${{ steps.myRequest.outputs.headers }}
|
echo ${{ steps.myRequest.outputs.headers }}
|
||||||
|
echo ${{ steps.myRequest.outputs.status }}
|
||||||
echo ${{ fromJson(steps.myRequest.outputs.response).field_you_want_to_access }}
|
echo ${{ fromJson(steps.myRequest.outputs.response).field_you_want_to_access }}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -100,4 +103,4 @@ Optionen:
|
|||||||
--bearerToken bearer token without Bearer prefix, added as
|
--bearerToken bearer token without Bearer prefix, added as
|
||||||
Authorization header [string]
|
Authorization header [string]
|
||||||
--timeout request timeout [number] [default: 5000]
|
--timeout request timeout [number] [default: 5000]
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ inputs:
|
|||||||
description: 'Auth Password'
|
description: 'Auth Password'
|
||||||
required: false
|
required: false
|
||||||
timeout:
|
timeout:
|
||||||
description: 'Request Timeout in Sec'
|
description: 'Request Timeout in milliseconds'
|
||||||
required: false
|
required: false
|
||||||
default: '5000'
|
default: '5000'
|
||||||
bearerToken:
|
bearerToken:
|
||||||
@@ -69,11 +69,16 @@ inputs:
|
|||||||
retryWait:
|
retryWait:
|
||||||
description: 'wait time between retries in milliseconds'
|
description: 'wait time between retries in milliseconds'
|
||||||
required: false
|
required: false
|
||||||
|
ignoreSsl:
|
||||||
|
description: 'ignore ssl verify (rejectUnauthorized: false)'
|
||||||
|
default: 'false'
|
||||||
outputs:
|
outputs:
|
||||||
response:
|
response:
|
||||||
description: 'HTTP Response Content'
|
description: 'HTTP Response Content'
|
||||||
headers:
|
headers:
|
||||||
description: 'HTTP Response Headers'
|
description: 'HTTP Response Headers'
|
||||||
|
status:
|
||||||
|
description: 'HTTP status message'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
2283
dist/index.js
vendored
2283
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
26
package-lock.json
generated
26
package-lock.json
generated
@@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "http-request-action",
|
"name": "http-request-action",
|
||||||
"version": "1.14.1",
|
"version": "1.14.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "http-request-action",
|
"name": "http-request-action",
|
||||||
"version": "1.14.1",
|
"version": "1.14.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1"
|
"@actions/core": "^1.10.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"axios": "^1.6",
|
"axios": "^1.7",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"yargs": "^17.7.2"
|
"yargs": "^17.7.2"
|
||||||
},
|
},
|
||||||
@@ -87,12 +87,12 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/axios": {
|
"node_modules/axios": {
|
||||||
"version": "1.6.2",
|
"version": "1.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz",
|
||||||
"integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==",
|
"integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.0",
|
"follow-redirects": "^1.15.6",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"proxy-from-env": "^1.1.0"
|
"proxy-from-env": "^1.1.0"
|
||||||
}
|
}
|
||||||
@@ -166,9 +166,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/follow-redirects": {
|
"node_modules/follow-redirects": {
|
||||||
"version": "1.15.3",
|
"version": "1.15.6",
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz",
|
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
||||||
"integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==",
|
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -288,9 +288,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "5.27.2",
|
"version": "5.28.4",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.27.2.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz",
|
||||||
"integrity": "sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==",
|
"integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/busboy": "^2.0.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
"homepage": "https://github.com/fjogeleit/http-request-action#readme",
|
"homepage": "https://github.com/fjogeleit/http-request-action#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"axios": "^1.6",
|
"axios": "^1.7",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"yargs": "^17.7.2"
|
"yargs": "^17.7.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ const { GithubActions } = require('../githubActions');
|
|||||||
const createOutputHandler = (actions) => (response) => {
|
const createOutputHandler = (actions) => (response) => {
|
||||||
actions.setOutput('response', JSON.stringify(response.data))
|
actions.setOutput('response', JSON.stringify(response.data))
|
||||||
actions.setOutput('headers', response.headers)
|
actions.setOutput('headers', response.headers)
|
||||||
|
actions.setOutput('status', response.status)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { createOutputHandler }
|
module.exports = { createOutputHandler }
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ const retry = async (callback, options) => {
|
|||||||
lastErr = err;
|
lastErr = err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < options.retries) {
|
if (i < options.retry) {
|
||||||
options.actions.warning(`#${i + 1} request failed: ${err}`);
|
options.actions.warning(`#${i + 1} request failed: ${err}`);
|
||||||
await sleep(options.sleep);
|
await sleep(options.sleep);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,10 +94,10 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
|
|||||||
} catch(error) {
|
} catch(error) {
|
||||||
if (error.response && options.ignoredCodes.includes(error.response.status)) {
|
if (error.response && options.ignoredCodes.includes(error.response.status)) {
|
||||||
actions.warning(`ignored status code: ${JSON.stringify({ code: error.response.status, message: error.response.data })}`)
|
actions.warning(`ignored status code: ${JSON.stringify({ code: error.response.status, message: error.response.data })}`)
|
||||||
|
|
||||||
return null
|
return error.response
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!error.response && error.request && options.preventFailureOnNoResponse) {
|
if (!error.response && error.request && options.preventFailureOnNoResponse) {
|
||||||
actions.warning(`no response received: ${JSON.stringify(error)}`);
|
actions.warning(`no response received: ${JSON.stringify(error)}`);
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ if (!!core.getInput('bearerToken')) {
|
|||||||
|
|
||||||
/** @type {axios.AxiosRequestConfig} */
|
/** @type {axios.AxiosRequestConfig} */
|
||||||
const instanceConfig = {
|
const instanceConfig = {
|
||||||
|
httpsAgent: new https.Agent({
|
||||||
|
rejectUnauthorized: core.getInput('ignoreSsl') !== 'true',
|
||||||
|
}),
|
||||||
baseURL: core.getInput('url', { required: true }),
|
baseURL: core.getInput('url', { required: true }),
|
||||||
timeout: parseInt(core.getInput('timeout') || 5000, 10),
|
timeout: parseInt(core.getInput('timeout') || 5000, 10),
|
||||||
headers: { ...headers, ...customHeaders }
|
headers: { ...headers, ...customHeaders }
|
||||||
@@ -58,7 +61,7 @@ if (!!core.getInput('retry')) {
|
|||||||
|
|
||||||
let retryWait = 3000
|
let retryWait = 3000
|
||||||
if (!!core.getInput('retryWait')) {
|
if (!!core.getInput('retryWait')) {
|
||||||
retry = parseInt(core.getInput('retryWait'))
|
retryWait = parseInt(core.getInput('retryWait'))
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = core.getInput('data') || '{}';
|
const data = core.getInput('data') || '{}';
|
||||||
@@ -102,4 +105,4 @@ request({ data, method, instanceConfig, files, file, actions, options }).then(re
|
|||||||
if (response && typeof response == 'object') {
|
if (response && typeof response == 'object') {
|
||||||
handler.forEach(h => h(response))
|
handler.forEach(h => h(response))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user