From 35336be18d125620ff3fe6713aa63d009876c984 Mon Sep 17 00:00:00 2001 From: Frank Jogeleit Date: Fri, 4 Mar 2022 11:26:59 +0100 Subject: [PATCH 1/3] Update README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2fe5e3c..e48a984 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,10 @@ jobs: password: ${{ secrets.AWX_PASSWORD }} ``` +### 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 | From 435fe1dbc8a4d49556e71f1fe36846149b7953c8 Mon Sep 17 00:00:00 2001 From: Jinu Noh <45530894+yesjinu@users.noreply.github.com> Date: Tue, 24 May 2022 19:22:08 +0900 Subject: [PATCH 2/3] docs: enhance README.md --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e48a984..efccf00 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ jobs: method: 'POST' username: ${{ secrets.AWX_USER }} password: ${{ secrets.AWX_PASSWORD }} + customHeaders: '{"Authorization": "Bearer ${{ secrets.TOKEN }}", "Content-Type": "application/json"}' + data: '{"key_1": "value_1", "key_2": "value_2"}' ``` ### Versioning @@ -46,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: @@ -56,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 From e3313c1a5f87ea3807b7034fb41abbb83a6533df Mon Sep 17 00:00:00 2001 From: Frank Jogeleit Date: Sat, 4 Jun 2022 10:52:53 +0200 Subject: [PATCH 3/3] Update Error Output Signed-off-by: Frank Jogeleit --- README.md | 2 +- dist/index.js | 5 +++-- src/httpClient.js | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index efccf00..0495974 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ jobs: method: 'POST' username: ${{ secrets.AWX_USER }} password: ${{ secrets.AWX_PASSWORD }} - customHeaders: '{"Authorization": "Bearer ${{ secrets.TOKEN }}", "Content-Type": "application/json"}' + customHeaders: '{"Content-Type": "application/json"}' data: '{"key_1": "value_1", "key_2": "value_2"}' ``` diff --git a/dist/index.js b/dist/index.js index 974d4e3..85dda49 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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)) { diff --git a/src/httpClient.js b/src/httpClient.js index c167ab6..6cef368 100644 --- a/src/httpClient.js +++ b/src/httpClient.js @@ -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)) {