Merge pull request #47 from fjogeleit/main

master merge
This commit is contained in:
Frank Jogeleit 2022-06-04 10:55:42 +02:00 committed by GitHub
commit fb4418ffc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions

View file

@ -15,8 +15,14 @@ jobs:
method: 'POST'
username: ${{ secrets.AWX_USER }}
password: ${{ secrets.AWX_PASSWORD }}
customHeaders: '{"Content-Type": "application/json"}'
data: '{"key_1": "value_1", "key_2": "value_2"}'
```
### Versioning
`master` branch is deprecated. Please use `main` or `v1` to get the latest version of this action. It is recommended to use a fixed version.
### Request Configuration
|Argument| Description | Default |
@ -42,7 +48,7 @@ jobs:
|---|---|
`response` | Response as JSON String
To display HTTP response data in the GitHub Actions log give the request an `id` and access its `outputs`
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.
```yaml
steps:
@ -52,7 +58,9 @@ steps:
with:
url: "http://yoursite.com/api"
- name: Show Response
run: echo ${{ steps.myRequest.outputs.response }}
run: |
echo ${{ steps.myRequest.outputs.response }}
echo ${{ fromJson(steps.myRequest.outputs.response).field_you_want_to_access }}
```
### Additional Information

5
dist/index.js vendored
View file

@ -1969,8 +1969,9 @@ const request = async({ method, instanceConfig, data, files, file, auth, actions
actions.setOutput('response', JSON.stringify(response.data))
} catch (error) {
if (error.toJSON) {
actions.setOutput('requestError', JSON.stringify(error.toJSON()));
if ((typeof error === 'object') && (error.isAxiosError === true)) {
const { name, message, code, response } = error
actions.setOutput('requestError', JSON.stringify({ name, message, code, status: response && response.status ? response.status : null }));
}
if (error.response && ignoredCodes.includes(error.response.status)) {

View file

@ -71,8 +71,9 @@ const request = async({ method, instanceConfig, data, files, file, auth, actions
actions.setOutput('response', JSON.stringify(response.data))
} catch (error) {
if (error.toJSON) {
actions.setOutput('requestError', JSON.stringify(error.toJSON()));
if ((typeof error === 'object') && (error.isAxiosError === true)) {
const { name, message, code, response } = error
actions.setOutput('requestError', JSON.stringify({ name, message, code, status: response && response.status ? response.status : null }));
}
if (error.response && ignoredCodes.includes(error.response.status)) {