mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2026-02-05 17:45:55 +08:00
Compare commits
86 Commits
support-fi
...
rebuild
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7887dd203d | ||
|
|
e2dc57c840 | ||
|
|
194a3f4e1f | ||
|
|
4c58a041ad | ||
|
|
35037b21f7 | ||
|
|
5706faf3f3 | ||
|
|
9c10705f37 | ||
|
|
6b94d84716 | ||
|
|
82eb846eb4 | ||
|
|
b2f2b61144 | ||
|
|
f84a4609c3 | ||
|
|
34ecd1d9f0 | ||
|
|
e44509028b | ||
|
|
33230fada8 | ||
|
|
a19855b3c5 | ||
|
|
b02ec78054 | ||
|
|
f3df2b2d06 | ||
|
|
50734d6ff5 | ||
|
|
e5f229f068 | ||
|
|
1709f318cd | ||
|
|
5c400e2bc4 | ||
|
|
b12240f543 | ||
|
|
90fd7d3206 | ||
|
|
18930d9c3a | ||
|
|
73373685ae | ||
|
|
5419a58b02 | ||
|
|
75020ad6eb | ||
|
|
465f4de861 | ||
|
|
cfb5583910 | ||
|
|
23ad54bcd1 | ||
|
|
1f693e5f61 | ||
|
|
4ea8974961 | ||
|
|
4d0fdb4907 | ||
|
|
93461a85b6 | ||
|
|
6b27404bb5 | ||
|
|
bc28d96e05 | ||
|
|
2f69e39476 | ||
|
|
9fa4000143 | ||
|
|
9803f436f3 | ||
|
|
bf78da1411 | ||
|
|
c54053fb4a | ||
|
|
46e3792733 | ||
|
|
4a50afee6f | ||
|
|
04043b9aef | ||
|
|
07eceb44a4 | ||
|
|
5cfc483290 | ||
|
|
53f5db2650 | ||
|
|
97bb93c5b1 | ||
|
|
64c456606f | ||
|
|
62761453c7 | ||
|
|
aeef78bb14 | ||
|
|
44816be1ea | ||
|
|
dea4657059 | ||
|
|
ae65a272d9 | ||
|
|
6cbe966de9 | ||
|
|
1e440b8b8c | ||
|
|
7d4a18ad25 | ||
|
|
ed8a1c36db | ||
|
|
8af2803109 | ||
|
|
8537e58734 | ||
|
|
74e0e96181 | ||
|
|
2bb8059d00 | ||
|
|
bfbe4dd6af | ||
|
|
7c708e96af | ||
|
|
f9dc1a8d4b | ||
|
|
33a4d079d7 | ||
|
|
0b6ec5eadd | ||
|
|
897b6a3c96 | ||
|
|
363da44e0a | ||
|
|
1a131d17cc | ||
|
|
72a0a5b93e | ||
|
|
606bb16fb9 | ||
|
|
517601f732 | ||
|
|
c9a231b621 | ||
|
|
2e6550f5bd | ||
|
|
caab55e3d8 | ||
|
|
997aeb8de8 | ||
|
|
0bd00a33db | ||
|
|
a665541d9c | ||
|
|
e23645bd9b | ||
|
|
897543ff26 | ||
|
|
3fee944184 | ||
|
|
c23f0d6631 | ||
|
|
6dd87961de | ||
|
|
d81c81a128 | ||
|
|
2d6a2f17dc |
2
.github/workflows/build-action.yml
vendored
2
.github/workflows/build-action.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout repo
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{ inputs.ref }}
|
||||
- uses: actions/setup-node@v4
|
||||
|
||||
117
.github/workflows/ci.yml
vendored
117
.github/workflows/ci.yml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
echo "branch=$branch" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- name: checkout repo
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
ref: ${{ steps.ref.outputs.branch }}
|
||||
- uses: actions/setup-node@v4
|
||||
@@ -56,7 +56,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout repo
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-node@v4
|
||||
@@ -69,116 +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" > testfile1.txt
|
||||
echo "test" > testfile2.txt
|
||||
|
||||
- name: Request Postman Echo POST Multipart
|
||||
uses: ./
|
||||
with:
|
||||
url: 'https://postman-echo.com/post'
|
||||
method: 'POST'
|
||||
data: '{ "key": "value" }'
|
||||
files: '{ "file": "${{ github.workspace }}/testfile1.txt" }'
|
||||
|
||||
- name: Request Postman Echo POST Multipart File Array
|
||||
uses: ./
|
||||
with:
|
||||
url: 'https://postman-echo.com/post'
|
||||
method: 'POST'
|
||||
data: '{ "key": "value" }'
|
||||
files: '{ "file": ["${{ github.workspace }}/testfile1.txt", "${{ github.workspace }}/testfile2.txt"] }'
|
||||
|
||||
- name: Request Postman Echo POST and persist response
|
||||
uses: ./
|
||||
with:
|
||||
url: 'https://postman-echo.com/post'
|
||||
method: 'POST'
|
||||
file: "${{ github.workspace }}/testfile1.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 }}/testfile1.txt" }'
|
||||
|
||||
- name: Request Postman Echo POST single file
|
||||
uses: ./
|
||||
with:
|
||||
url: 'https://postman-echo.com/post'
|
||||
method: 'POST'
|
||||
file: "${{ github.workspace }}/testfile1.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
337
.github/workflows/it-tests.yml
vendored
Normal 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 # 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) }}
|
||||
@@ -45,8 +45,10 @@ jobs:
|
||||
|httpsCert| Client Certificate as string ||
|
||||
|httpsKey| Client Certificate Key as string ||
|
||||
|responseFile| Persist the response data to the specified file path ||
|
||||
|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
|
||||
|
||||
@@ -54,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.
|
||||
|
||||
@@ -68,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 }}
|
||||
```
|
||||
|
||||
@@ -99,4 +103,4 @@ Optionen:
|
||||
--bearerToken bearer token without Bearer prefix, added as
|
||||
Authorization header [string]
|
||||
--timeout request timeout [number] [default: 5000]
|
||||
```
|
||||
```
|
||||
|
||||
13
action.yml
13
action.yml
@@ -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:
|
||||
@@ -59,17 +59,26 @@ inputs:
|
||||
responseFile:
|
||||
description: 'Persist the response data to the specified file path'
|
||||
required: false
|
||||
maskResponse:
|
||||
description: 'Allows to mark your response as secret and hide the output in the action logs'
|
||||
required: false
|
||||
default: 'false'
|
||||
retry:
|
||||
description: 'optional amount of retries if the request fails'
|
||||
required: false
|
||||
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'
|
||||
|
||||
8097
dist/index.js
vendored
8097
dist/index.js
vendored
File diff suppressed because one or more lines are too long
3213
package-lock.json
generated
3213
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "http-request-action",
|
||||
"version": "1.14.2",
|
||||
"version": "1.16.4",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"private": false,
|
||||
@@ -19,15 +19,13 @@
|
||||
},
|
||||
"homepage": "https://github.com/fjogeleit/http-request-action#readme",
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"axios": "^1.6",
|
||||
"form-data": "^4.0.0",
|
||||
"yargs": "^17.7.2"
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"axios": "^1.12",
|
||||
"form-data": "^4.0.3",
|
||||
"yargs": "^18.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.1",
|
||||
"install": "^0.13.0",
|
||||
"npm": "^10.2.4"
|
||||
"@actions/core": "^1.11.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
|
||||
@@ -19,6 +19,10 @@ class GithubActions {
|
||||
core.setOutput(name, output)
|
||||
}
|
||||
|
||||
setSecret(value) {
|
||||
core.setSecret(value)
|
||||
}
|
||||
|
||||
setFailed(message) {
|
||||
core.setFailed(message)
|
||||
}
|
||||
|
||||
15
src/handler/mask.js
Normal file
15
src/handler/mask.js
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict'
|
||||
|
||||
const axios = require('axios');
|
||||
const { GithubActions } = require('../githubActions');
|
||||
|
||||
/**
|
||||
* @param {GithubActions} actions
|
||||
*
|
||||
* @returns {(response: axios.AxiosResponse) => void}
|
||||
*/
|
||||
const createMaskHandler = (actions) => (response) => {
|
||||
actions.setSecret(JSON.stringify(response.data))
|
||||
}
|
||||
|
||||
module.exports = { createMaskHandler }
|
||||
17
src/handler/output.js
Normal file
17
src/handler/output.js
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict'
|
||||
|
||||
const axios = require('axios');
|
||||
const { GithubActions } = require('../githubActions');
|
||||
|
||||
/**
|
||||
* @param {GithubActions} actions
|
||||
*
|
||||
* @returns {(response: axios.AxiosResponse) => void}
|
||||
*/
|
||||
const createOutputHandler = (actions) => (response) => {
|
||||
actions.setOutput('response', JSON.stringify(response.data))
|
||||
actions.setOutput('headers', response.headers)
|
||||
actions.setOutput('status', response.status)
|
||||
}
|
||||
|
||||
module.exports = { createOutputHandler }
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ const convertToJSON = (value) => {
|
||||
*
|
||||
* @returns {FormData}
|
||||
*/
|
||||
const convertToFormData = async (data, files, convertPaths) => {
|
||||
const convertToFormData = (data, files) => {
|
||||
const formData = new FormData();
|
||||
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
@@ -32,11 +32,7 @@ const convertToFormData = async (data, files, convertPaths) => {
|
||||
}
|
||||
|
||||
for (const [key, value] of Object.entries(files)) {
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(v => formData.append(key, fs.createReadStream(v)))
|
||||
} else {
|
||||
formData.append(key, fs.createReadStream(value));
|
||||
}
|
||||
formData.append(key, fs.createReadStream(value));
|
||||
}
|
||||
|
||||
return formData;
|
||||
@@ -59,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,11 +53,17 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
|
||||
if (Object.keys(filesJson).length > 0) {
|
||||
try {
|
||||
data = convertToFormData(dataJson, filesJson)
|
||||
instanceConfig = await updateConfig(instanceConfig, data, actions)
|
||||
} catch(error) {
|
||||
actions.setFailed(JSON.stringify({ message: `Unable to convert Data and Files into FormData: ${error.message}`, data: dataJson, files: filesJson }))
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
instanceConfig = await updateConfig(instanceConfig, data)
|
||||
} catch(error) {
|
||||
actions.setFailed(JSON.stringify({ message: `Unable to read Content-Length: ${error.message}` }))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,10 +100,10 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
|
||||
} catch(error) {
|
||||
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) {
|
||||
actions.warning(`no response received: ${JSON.stringify(error)}`);
|
||||
|
||||
@@ -119,9 +125,6 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
|
||||
return null
|
||||
}
|
||||
|
||||
actions.setOutput('response', JSON.stringify(response.data))
|
||||
actions.setOutput('headers', response.headers)
|
||||
|
||||
return response
|
||||
} catch (error) {
|
||||
if ((typeof error === 'object') && (error.isAxiosError === true)) {
|
||||
@@ -132,7 +135,7 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
|
||||
if (error.response) {
|
||||
actions.setFailed(JSON.stringify({ code: error.response.status, message: error.response.data }))
|
||||
} else if (error.request) {
|
||||
actions.setFailed(JSON.stringify({ error: "no response received" }));
|
||||
actions.setFailed(JSON.stringify({ error: "no response received", message: error.message }));
|
||||
} else {
|
||||
actions.setFailed(JSON.stringify({ message: error.message, data }));
|
||||
}
|
||||
@@ -142,12 +145,10 @@ const request = async({ method, instanceConfig, data, files, file, actions, opti
|
||||
/**
|
||||
* @param {{ baseURL: string; timeout: number; headers: { [name: string]: string } }} instanceConfig
|
||||
* @param {FormData} formData
|
||||
* @param {*} actions
|
||||
*
|
||||
* @returns {Promise<{ baseURL: string; timeout: number; headers: { [name: string]: string } }>}
|
||||
*/
|
||||
const updateConfig = async (instanceConfig, formData, actions) => {
|
||||
try {
|
||||
const updateConfig = async (instanceConfig, formData) => {
|
||||
const formHeaders = formData.getHeaders()
|
||||
const contentType = formHeaders['content-type']
|
||||
|
||||
@@ -162,9 +163,6 @@ const updateConfig = async (instanceConfig, formData, actions) => {
|
||||
'Content-Type': contentType
|
||||
}
|
||||
}
|
||||
} catch(error) {
|
||||
actions.setFailed({ message: `Unable to read Content-Length: ${error.message}`, data, files })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,9 +195,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
|
||||
}
|
||||
|
||||
|
||||
21
src/index.js
21
src/index.js
@@ -5,7 +5,10 @@ const axios = require('axios');
|
||||
const https = require('https');
|
||||
const { request, METHOD_POST } = require('./httpClient');
|
||||
const { GithubActions } = require('./githubActions');
|
||||
|
||||
const { createPersistHandler } = require('./handler/persist');
|
||||
const { createOutputHandler } = require('./handler/output');
|
||||
const { createMaskHandler } = require('./handler/mask');
|
||||
|
||||
let customHeaders = {}
|
||||
|
||||
@@ -26,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 }
|
||||
@@ -55,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') || '{}';
|
||||
@@ -73,9 +79,16 @@ if (typeof ignoreStatusCodes === 'string' && ignoreStatusCodes.length > 0) {
|
||||
ignoredCodes = ignoreStatusCodes.split(',').map(statusCode => parseInt(statusCode.trim()))
|
||||
}
|
||||
|
||||
const handler = [];
|
||||
const actions = new GithubActions();
|
||||
|
||||
const handler = [];
|
||||
|
||||
if (core.getBooleanInput('maskResponse')) {
|
||||
handler.push(createMaskHandler(actions))
|
||||
}
|
||||
|
||||
handler.push(createOutputHandler(actions))
|
||||
|
||||
if (!!responseFile) {
|
||||
handler.push(createPersistHandler(responseFile, actions))
|
||||
}
|
||||
@@ -89,7 +102,7 @@ const options = {
|
||||
}
|
||||
|
||||
request({ data, method, instanceConfig, files, file, actions, options }).then(response => {
|
||||
if (typeof response == 'object') {
|
||||
if (response && typeof response == 'object') {
|
||||
handler.forEach(h => h(response))
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user