Merge pull request #164 from fjogeleit/main

master sync
This commit is contained in:
Frank Jogeleit 2024-09-10 15:19:42 +02:00 committed by GitHub
commit 60b4626721
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 2398 additions and 933 deletions

View file

@ -69,106 +69,3 @@ jobs:
- name: Repository Integrity Check
run: |
git diff --quiet dist
test:
if: >
!failure() &&
!cancelled()
needs:
- integrity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Request Postman Echo GET
uses: ./
with:
url: 'https://postman-echo.com/get'
method: 'GET'
- name: Request Postman Echo POST
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
data: '{ "key": "value" }'
- name: Request Postman Echo POST with Unescaped Newline
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
escapeData: 'true'
data: >-
{
"key":"multi line\ntest
text"
}
- name: Request Postman Echo BasicAuth
uses: ./
with:
url: 'https://postman-echo.com/basic-auth'
method: 'GET'
username: 'postman'
password: 'password'
- name: Request Postman Echo with 404 Response and ignore failure code
uses: ./
with:
url: 'https://postman-echo.com/status/404'
method: 'GET'
ignoreStatusCodes: '404'
- name: Create Test File
run: |
echo "test" > testfile.txt
- name: Request Postman Echo POST Multipart
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
data: '{ "key": "value" }'
files: '{ "file": "${{ github.workspace }}/testfile.txt" }'
- name: Request Postman Echo POST and persist response
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
file: "${{ github.workspace }}/testfile.txt"
responseFile: "${{ github.workspace }}/response.json"
- name: Output responseFile
run: |
cat "${{ github.workspace }}/response.json"
- name: Request Postman Echo POST Multipart without data
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
files: '{ "file": "${{ github.workspace }}/testfile.txt" }'
- name: Request Postman Echo POST single file
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
file: "${{ github.workspace }}/testfile.txt"
- name: Request Postman Echo POST URLEncoded string data
uses: ./
with:
url: 'https://postman-echo.com/post'
contentType : 'application/x-www-form-urlencoded'
method: 'POST'
data: 'key=value'
- name: Request Postman Echo POST URLEncoded json data
uses: ./
with:
url: 'https://postman-echo.com/post'
contentType : 'application/x-www-form-urlencoded'
method: 'POST'
data: '{"key":"value"}'

337
.github/workflows/it-tests.yml vendored Normal file
View file

@ -0,0 +1,337 @@
on:
pull_request:
push:
branches: [main]
jobs:
test-method-get-on-existing-url:
name: "IT Test - Request Postman Echo GET"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with GET and a valid URL
id: execution
uses: ./
with:
url: 'https://postman-echo.com/get'
method: 'GET'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-method-post-on-existing-url:
name: "IT Test - Request Postman Echo POST"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with POST using valid data
id: execution
uses: ./
with:
url: "https://postman-echo.com/post"
method: 'POST'
data: '{ "key": "value" }'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-method-post-on-existing-url-with-unescaped-newline:
name: "IT Test - Request Postman Echo POST with Unescaped Newline"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with POST using unescaped new line within data
id: execution
uses: ./
with:
url: "https://postman-echo.com/post"
method: 'POST'
escapeData: 'true'
data: >-
{
"key":"multi line\ntest
text"
}
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-basic-auth:
name: "IT Test - Request Postman Echo BasicAuth"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with valid BasicAuth parameters
id: execution
uses: ./
with:
url: 'https://postman-echo.com/basic-auth'
method: 'GET'
username: 'postman'
password: 'password'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200 as this URL exists
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-ignore-failure-code-404:
name: "IT Test - Request Postman Echo with 404 Response and ignore failure code"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with unknown URL and ignoreStatusCode 404 for it
id: execution
uses: ./
with:
url: 'https://postman-echo.com/status/404'
method: 'GET'
ignoreStatusCodes: '404'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must 404
with:
expected: '404'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then the outcome value must be success as the error 404 is ignored
with:
expected: 'success'
actual: ${{ steps.execution.outcome }}
comparison: exact
test-input-ignore-failure-multiple-codes-401-404:
name: "IT Test - Request Postman Echo with 404 Response and ignore failure code"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with unknown URL and ignore status codes 401,404
id: execution
uses: ./
with:
url: 'https://postman-echo.com/status/404'
method: 'GET'
ignoreStatusCodes: '401,404'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 404
with:
expected: '404'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then the outcome value must be success as the error 404 is ignored
with:
expected: 'success'
actual: ${{ steps.execution.outcome }}
comparison: exact
test-input-files:
name: "IT Test - Request Postman Echo POST Multipart"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile.txt
- name: Given the gh-action is used with file and data
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
data: '{ "key": "value" }'
files: '{ "file": "${{ github.workspace }}/testfile.txt" }'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-responseFile:
name: "IT Test - Request Postman Echo POST and persist response"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile2.txt
- name: Given the gh-action is used with file and responseFile
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
file: "${{ github.workspace }}/testfile2.txt"
responseFile: "${{ github.workspace }}/response.json"
- name: Output responseFile
id: execution-response-file
run: |
echo "response_content=$(cat ${{ github.workspace }}/response.json)" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.response_content value must include
with:
expected: '{"args":{},"data":"test\n","files":{},"form":{},"headers":{"host":"postman-echo.com",'
actual: ${{ steps.execution-response-file.outputs.response_content }}
comparison: contains
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.response_content value must include
with:
expected: '"accept":"application/json, text/plain, */*","content-type":"application/json","user-agent"'
actual: ${{ steps.execution-response-file.outputs.response_content }}
comparison: contains
test-input-files-without-data:
name: "IT Test - Request Postman Echo POST Multipart without data"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile3.txt
- name: Given the gh-action is used with file
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
files: '{ "file": "${{ github.workspace }}/testfile3.txt" }'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-file-with-single-file:
name: "IT Test - Request Postman Echo POST single file"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile4.txt
- name: Given the gh-action is used with file
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
file: "${{ github.workspace }}/testfile4.txt"
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-data-with-url-encoded-string:
name: "IT Test - Request Postman Echo POST URLEncoded string data"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with data form url encoded
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
contentType : 'application/x-www-form-urlencoded'
method: 'POST'
data: 'key=value'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-data-with-url-encoded-json-data:
name: "IT Test - Request Postman Echo POST URLEncoded json data"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with json data
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
contentType : 'application/x-www-form-urlencoded'
method: 'POST'
data: '{"key":"value"}'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-delete-http-method:
name: "IT Test - Request Postman Echo DELETE"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with method DELETE
id: execution
uses: ./
with:
url: 'https://postman-echo.com/delete'
contentType : 'application/json'
method: 'DELETE'
data: '{"key":"value"}'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
it-tests:
name: "All IT Tests have to pass"
runs-on: ubuntu-latest
if: always()
needs:
# Add your tests here so that they prevent the merge of broken changes
- test-method-get-on-existing-url
- test-method-post-on-existing-url
- test-method-post-on-existing-url-with-unescaped-newline
- test-basic-auth
- test-input-ignore-failure-code-404
- test-input-ignore-failure-multiple-codes-401-404
- test-input-files
- test-input-responseFile
- test-input-files-without-data
- test-input-file-with-single-file
- test-input-data-with-url-encoded-string
- test-input-data-with-url-encoded-json-data
- test-delete-http-method
steps:
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
jobs: ${{ toJSON(needs) }}

View file

@ -45,9 +45,10 @@ jobs:
|httpsCert| Client Certificate as string ||
|httpsKey| Client Certificate Key as string ||
|responseFile| Persist the response data to the specified file path ||
|markResponse| If set to true, the response will be masked in the logs of the action |'false'|
|maskResponse| If set to true, the response will be masked in the logs of the action |'false'|
|retry| optional amount of retries if the request is failing, does not retry if the status code is ignored ||
|retryWait| time between each retry in millseconds | 3000 |
|ignoreSsl| ignore ssl verify (rejectUnauthorized: false) | false |
### Response
@ -55,6 +56,7 @@ jobs:
|---|---|
`response` | Response as JSON String
`headers` | Headers
`status` | HTTP status message
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.
@ -69,6 +71,7 @@ steps:
run: |
echo ${{ steps.myRequest.outputs.response }}
echo ${{ steps.myRequest.outputs.headers }}
echo ${{ steps.myRequest.outputs.status }}
echo ${{ fromJson(steps.myRequest.outputs.response).field_you_want_to_access }}
```

View file

@ -29,7 +29,7 @@ inputs:
description: 'Auth Password'
required: false
timeout:
description: 'Request Timeout in Sec'
description: 'Request Timeout in milliseconds'
required: false
default: '5000'
bearerToken:
@ -69,11 +69,16 @@ inputs:
retryWait:
description: 'wait time between retries in milliseconds'
required: false
ignoreSsl:
description: 'ignore ssl verify (rejectUnauthorized: false)'
default: 'false'
outputs:
response:
description: 'HTTP Response Content'
headers:
description: 'HTTP Response Headers'
status:
description: 'HTTP status message'
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'

2709
dist/index.js vendored

File diff suppressed because it is too large Load diff

84
package-lock.json generated
View file

@ -1,19 +1,19 @@
{
"name": "http-request-action",
"version": "1.14.1",
"version": "1.14.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "http-request-action",
"version": "1.14.1",
"version": "1.14.2",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.1"
},
"devDependencies": {
"@vercel/ncc": "^0.38.1",
"axios": "^1.6",
"axios": "^1.7",
"form-data": "^4.0.0",
"yargs": "^17.7.2"
},
@ -25,24 +25,27 @@
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
"license": "MIT",
"dependencies": {
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
}
},
"node_modules/@actions/http-client": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.0.tgz",
"integrity": "sha512-q+epW0trjVUUHboliPb4UF9g2msf+w61b32tAkFEwL/IwP0DQWgbCMM0Hbe3e3WXSKz5VcUXbzJQgy8Hkra/Lg==",
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.3.tgz",
"integrity": "sha512-mx8hyJi/hjFvbPokCg4uRd4ZX78t+YyRPtnKWwIl+RzNaVuFpQHfmlGVfsKEJN8LwTCvL+DfVgAM04XaHkm6bA==",
"license": "MIT",
"dependencies": {
"tunnel": "^0.0.6",
"undici": "^5.25.4"
}
},
"node_modules/@fastify/busboy": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz",
"integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
"license": "MIT",
"engines": {
"node": ">=14"
}
@ -52,6 +55,7 @@
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.1.tgz",
"integrity": "sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==",
"dev": true,
"license": "MIT",
"bin": {
"ncc": "dist/ncc/cli.js"
}
@ -61,6 +65,7 @@
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
@ -70,6 +75,7 @@
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
},
@ -84,15 +90,17 @@
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
"dev": true
"dev": true,
"license": "MIT"
},
"node_modules/axios": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz",
"integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==",
"version": "1.7.7",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz",
"integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.0",
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
@ -102,6 +110,7 @@
"resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz",
"integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==",
"dev": true,
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.1",
@ -116,6 +125,7 @@
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
},
@ -127,13 +137,15 @@
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
"dev": true,
"license": "MIT"
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dev": true,
"license": "MIT",
"dependencies": {
"delayed-stream": "~1.0.0"
},
@ -146,6 +158,7 @@
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.4.0"
}
@ -154,21 +167,23 @@
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true
"dev": true,
"license": "MIT"
},
"node_modules/escalade": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
"integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==",
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/follow-redirects": {
"version": "1.15.3",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz",
"integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==",
"version": "1.15.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
"dev": true,
"funding": [
{
@ -176,6 +191,7 @@
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"license": "MIT",
"engines": {
"node": ">=4.0"
},
@ -190,6 +206,7 @@
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dev": true,
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
@ -204,6 +221,7 @@
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"dev": true,
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
@ -213,6 +231,7 @@
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
@ -222,6 +241,7 @@
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
@ -231,6 +251,7 @@
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dev": true,
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
@ -242,13 +263,15 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
"dev": true
"dev": true,
"license": "MIT"
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
@ -258,6 +281,7 @@
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
@ -272,6 +296,7 @@
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
@ -283,14 +308,16 @@
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
"license": "MIT",
"engines": {
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
}
},
"node_modules/undici": {
"version": "5.27.2",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.27.2.tgz",
"integrity": "sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==",
"version": "5.28.4",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz",
"integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==",
"license": "MIT",
"dependencies": {
"@fastify/busboy": "^2.0.0"
},
@ -302,6 +329,7 @@
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"license": "MIT",
"bin": {
"uuid": "dist/bin/uuid"
}
@ -311,6 +339,7 @@
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
@ -328,6 +357,7 @@
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=10"
}
@ -337,6 +367,7 @@
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz",
"integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==",
"dev": true,
"license": "MIT",
"dependencies": {
"cliui": "^8.0.1",
"escalade": "^3.1.1",
@ -355,6 +386,7 @@
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=12"
}

View file

@ -20,7 +20,7 @@
"homepage": "https://github.com/fjogeleit/http-request-action#readme",
"devDependencies": {
"@vercel/ncc": "^0.38.1",
"axios": "^1.6",
"axios": "^1.7",
"form-data": "^4.0.0",
"yargs": "^17.7.2"
},

View file

@ -9,13 +9,7 @@ const { GithubActions } = require('../githubActions');
* @returns {(response: axios.AxiosResponse) => void}
*/
const createMaskHandler = (actions) => (response) => {
let data = response.data
if (typeof data == 'object') {
data = JSON.stringify(data)
}
actions.setSecret(data)
actions.setSecret(JSON.stringify(response.data))
}
module.exports = { createMaskHandler }

View file

@ -9,8 +9,9 @@ const { GithubActions } = require('../githubActions');
* @returns {(response: axios.AxiosResponse) => void}
*/
const createOutputHandler = (actions) => (response) => {
actions.setOutput('response', response.data)
actions.setOutput('response', JSON.stringify(response.data))
actions.setOutput('headers', response.headers)
actions.setOutput('status', response.status)
}
module.exports = { createOutputHandler }

View file

@ -17,8 +17,8 @@ const createPersistHandler = (filePath, actions) => (response) => {
data = JSON.stringify(data)
}
fs.writeFile(filePath, data, err => {
if (!err) {
fs.writeFile(filePath, data, error => {
if (!error) {
actions.info(`response persisted successfully at ${filePath}`)
return
}

View file

@ -55,8 +55,8 @@ const retry = async (callback, options) => {
lastErr = err;
}
if (i < options.retries) {
options.actions.warning(`#${i + 1} request failed: ${err}`);
if (i < options.retry) {
options.actions.warning(`#${i + 1} request failed: ${lastErr}`);
await sleep(options.sleep);
}

View file

@ -95,7 +95,7 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
if (error.response && options.ignoredCodes.includes(error.response.status)) {
actions.warning(`ignored status code: ${JSON.stringify({ code: error.response.status, message: error.response.data })}`)
return null
return error.response
}
if (!error.response && error.request && options.preventFailureOnNoResponse) {
@ -194,9 +194,9 @@ const updateConfigForFile = (instanceConfig, filePath, actions) => {
* @returns {Promise<number>}
*/
const contentLength = (formData) => new Promise((resolve, reject) => {
formData.getLength((err, length) => {
if (err) {
reject (err)
formData.getLength((error, length) => {
if (error) {
reject(error)
return
}

View file

@ -29,6 +29,9 @@ if (!!core.getInput('bearerToken')) {
/** @type {axios.AxiosRequestConfig} */
const instanceConfig = {
httpsAgent: new https.Agent({
rejectUnauthorized: core.getInput('ignoreSsl') !== 'true',
}),
baseURL: core.getInput('url', { required: true }),
timeout: parseInt(core.getInput('timeout') || 5000, 10),
headers: { ...headers, ...customHeaders }
@ -58,7 +61,7 @@ if (!!core.getInput('retry')) {
let retryWait = 3000
if (!!core.getInput('retryWait')) {
retry = parseInt(core.getInput('retryWait'))
retryWait = parseInt(core.getInput('retryWait'))
}
const data = core.getInput('data') || '{}';