Merge pull request #52 from fjogeleit/main

master sync
This commit is contained in:
Frank Jogeleit 2022-08-17 10:40:08 +02:00 committed by GitHub
commit 315ec27690
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 0 deletions

View file

@ -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 }}
``` ```

View file

@ -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
View file

@ -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

View file

@ -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