From cfc342658b0b19b81ee41bc09f3dca438e1123c7 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 21 Apr 2020 13:44:56 +0200 Subject: [PATCH 1/7] Add Test Action --- .github/test.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/test.yml diff --git a/.github/test.yml b/.github/test.yml new file mode 100644 index 0000000..e252825 --- /dev/null +++ b/.github/test.yml @@ -0,0 +1,17 @@ +name: Test + +on: [push, pull_request] + +jobs: + request: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + + - name: Request Google Test + uses: ./ + with: + url: 'https://google.de' + method: 'GET' From 3b9f5efa1c3343b9ba8a8e680024baf0940fb1d6 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 21 Apr 2020 13:47:34 +0200 Subject: [PATCH 2/7] Move workflow in the right folder --- .github/{ => workflows}/test.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/test.yml (100%) diff --git a/.github/test.yml b/.github/workflows/test.yml similarity index 100% rename from .github/test.yml rename to .github/workflows/test.yml From 193a7dd98c312bd6b55676102a4483f42f5d9e99 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 21 Apr 2020 13:55:30 +0200 Subject: [PATCH 3/7] update data payload --- .github/workflows/test.yml | 4 ++-- dist/index.js | 10 ++++++++-- src/index.js | 10 ++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e252825..522037b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,8 +10,8 @@ jobs: with: ref: ${{ github.ref }} - - name: Request Google Test + - name: Request Postment Echo GET uses: ./ with: - url: 'https://google.de' + url: 'https://postman-echo.com/get' method: 'GET' diff --git a/dist/index.js b/dist/index.js index 00e16ba..62e44c1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2597,6 +2597,9 @@ module.exports = function httpAdapter(config) { const core = __webpack_require__(470); const axios = __webpack_require__(53); +const METHOD_GET = 'GET' +const METHOD_POST = 'POST' + let auth = undefined let customHeaders = {} @@ -2635,10 +2638,13 @@ const instance = axios.create(instanceConfig); (async() => { try { + const method = core.getInput('method') || METHOD_POST; + const data = method === METHOD_GET ? undefined : JSON.parse(core.getInput('data') || '{}') + const requestData = { auth, - method: core.getInput('method') || 'POST', - data: JSON.parse(core.getInput('data') || '{}') + method, + data } core.debug(JSON.stringify(requestData)) diff --git a/src/index.js b/src/index.js index bd613bf..8d230d2 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,9 @@ const core = require("@actions/core"); const axios = require("axios"); +const METHOD_GET = 'GET' +const METHOD_POST = 'POST' + let auth = undefined let customHeaders = {} @@ -39,10 +42,13 @@ const instance = axios.create(instanceConfig); (async() => { try { + const method = core.getInput('method') || METHOD_POST; + const data = method === METHOD_GET ? undefined : JSON.parse(core.getInput('data') || '{}') + const requestData = { auth, - method: core.getInput('method') || 'POST', - data: JSON.parse(core.getInput('data') || '{}') + method, + data } core.debug(JSON.stringify(requestData)) From 65d4ab42a4a5d02f50723c87847d94a77147735a Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 21 Apr 2020 13:58:56 +0200 Subject: [PATCH 4/7] add post test --- .github/workflows/test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 522037b..a83ad49 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,3 +15,10 @@ jobs: with: url: 'https://postman-echo.com/get' method: 'GET' + + - name: Request Postment Echo POST + uses: ./ + with: + url: 'https://postman-echo.com/post' + method: 'POST' + data: '{ "key": "value" }' From b9373e0ef3de37c9b11ea1e251ed791ea230757c Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 21 Apr 2020 14:07:56 +0200 Subject: [PATCH 5/7] add auth test --- .github/workflows/test.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a83ad49..f2d07f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,3 +22,11 @@ jobs: url: 'https://postman-echo.com/post' method: 'POST' data: '{ "key": "value" }' + + - name: Request Postment Echo BasicAuth + uses: ./ + with: + url: 'https://postman-echo.com/basic-auth' + method: 'POST' + username: 'postman' + password: 'password' From 8ed097ea3f54f0c890dd6e2b1934e90ae8e01418 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 21 Apr 2020 14:09:38 +0200 Subject: [PATCH 6/7] fix basic auth method --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f2d07f8..e6cb058 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,6 @@ jobs: uses: ./ with: url: 'https://postman-echo.com/basic-auth' - method: 'POST' + method: 'GET' username: 'postman' password: 'password' From acd894b2e10aedfc2081405c0aa5f355493f4e8c Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 21 Apr 2020 14:16:49 +0200 Subject: [PATCH 7/7] update readme --- README.md | 8 ++++++++ dist/index.js | 4 ++-- src/index.js | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3ecfd9f..e8a9bf8 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,11 @@ jobs: ### Output - `response` Request Response as JSON String + + +### Debug Informations + +Enable Debug mode to get informations about + +- Instance Configuration (Url / Timeout / Headers) +- Request Data (Body / Auth / Method) \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 62e44c1..a5250f6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2632,7 +2632,7 @@ const instanceConfig = { headers: { ...headers, ...customHeaders } } -core.debug(JSON.stringify(instanceConfig)) +core.debug('Instance Configuration: ' + JSON.stringify(instanceConfig)) const instance = axios.create(instanceConfig); @@ -2647,7 +2647,7 @@ const instance = axios.create(instanceConfig); data } - core.debug(JSON.stringify(requestData)) + core.debug('Request Data: ' + JSON.stringify(requestData)) const response = await instance.request(requestData) diff --git a/src/index.js b/src/index.js index 8d230d2..44a22bb 100644 --- a/src/index.js +++ b/src/index.js @@ -36,7 +36,7 @@ const instanceConfig = { headers: { ...headers, ...customHeaders } } -core.debug(JSON.stringify(instanceConfig)) +core.debug('Instance Configuration: ' + JSON.stringify(instanceConfig)) const instance = axios.create(instanceConfig); @@ -51,7 +51,7 @@ const instance = axios.create(instanceConfig); data } - core.debug(JSON.stringify(requestData)) + core.debug('Request Data: ' + JSON.stringify(requestData)) const response = await instance.request(requestData)