mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2024-11-22 11:51:03 -05:00
commit
315ec27690
4 changed files with 9 additions and 0 deletions
|
@ -41,12 +41,14 @@ jobs:
|
||||||
|escapeData| Escape newlines in data string content. Use 'true' (string) as value to enable it ||
|
|escapeData| Escape newlines in data string content. Use 'true' (string) as value to enable it ||
|
||||||
|preventFailureOnNoResponse| Prevent this Action to fail if the request respond without an response. Use 'true' (string) as value to enable it ||
|
|preventFailureOnNoResponse| Prevent this Action to fail if the request respond without an response. Use 'true' (string) as value to enable it ||
|
||||||
|ignoreStatusCodes| Prevent this Action to fail if the request respond with one of the configured Status Codes. Example: '404,401' ||
|
|ignoreStatusCodes| Prevent this Action to fail if the request respond with one of the configured Status Codes. Example: '404,401' ||
|
||||||
|
|httpsCA| Certificate authority as string in PEM format ||
|
||||||
|
|
||||||
### Response
|
### Response
|
||||||
|
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
|---|---|
|
|---|---|
|
||||||
`response` | Response as JSON String
|
`response` | Response as JSON String
|
||||||
|
`headers` | Headers
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
@ -60,6 +62,7 @@ steps:
|
||||||
- name: Show Response
|
- name: Show Response
|
||||||
run: |
|
run: |
|
||||||
echo ${{ steps.myRequest.outputs.response }}
|
echo ${{ steps.myRequest.outputs.response }}
|
||||||
|
echo ${{ steps.myRequest.outputs.headers }}
|
||||||
echo ${{ fromJson(steps.myRequest.outputs.response).field_you_want_to_access }}
|
echo ${{ fromJson(steps.myRequest.outputs.response).field_you_want_to_access }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,8 @@ inputs:
|
||||||
outputs:
|
outputs:
|
||||||
response:
|
response:
|
||||||
description: 'HTTP Response Content'
|
description: 'HTTP Response Content'
|
||||||
|
headers:
|
||||||
|
description: 'HTTP Response Headers'
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
|
@ -1968,6 +1968,8 @@ const request = async({ method, instanceConfig, data, files, file, actions, igno
|
||||||
const response = await instance.request(requestData)
|
const response = await instance.request(requestData)
|
||||||
|
|
||||||
actions.setOutput('response', JSON.stringify(response.data))
|
actions.setOutput('response', JSON.stringify(response.data))
|
||||||
|
|
||||||
|
actions.setOutput('headers', response.headers)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if ((typeof error === 'object') && (error.isAxiosError === true)) {
|
if ((typeof error === 'object') && (error.isAxiosError === true)) {
|
||||||
const { name, message, code, response } = error
|
const { name, message, code, response } = error
|
||||||
|
|
|
@ -68,6 +68,8 @@ const request = async({ method, instanceConfig, data, files, file, actions, igno
|
||||||
const response = await instance.request(requestData)
|
const response = await instance.request(requestData)
|
||||||
|
|
||||||
actions.setOutput('response', JSON.stringify(response.data))
|
actions.setOutput('response', JSON.stringify(response.data))
|
||||||
|
|
||||||
|
actions.setOutput('headers', response.headers)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if ((typeof error === 'object') && (error.isAxiosError === true)) {
|
if ((typeof error === 'object') && (error.isAxiosError === true)) {
|
||||||
const { name, message, code, response } = error
|
const { name, message, code, response } = error
|
||||||
|
|
Loading…
Reference in a new issue