mirror of
https://github.com/fjogeleit/http-request-action.git
synced 2026-02-05 00:55:52 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6980b2ca5 | ||
|
|
70ee000b97 | ||
|
|
5e30e204fc | ||
|
|
82d22dd60f | ||
|
|
1ea54adf35 | ||
|
|
8e939c608a | ||
|
|
7c5a3f2e70 | ||
|
|
78bba76cbe | ||
|
|
3e3e6b3eec | ||
|
|
0929a0c636 |
18
.github/workflows/test.yml
vendored
18
.github/workflows/test.yml
vendored
@@ -10,20 +10,20 @@ jobs:
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
- name: Request Postment Echo GET
|
||||
- name: Request Postman Echo GET
|
||||
uses: ./
|
||||
with:
|
||||
url: 'https://postman-echo.com/get'
|
||||
method: 'GET'
|
||||
|
||||
- name: Request Postment Echo POST
|
||||
- name: Request Postman Echo POST
|
||||
uses: ./
|
||||
with:
|
||||
url: 'https://postman-echo.com/post'
|
||||
method: 'POST'
|
||||
data: '{ "key": "value" }'
|
||||
|
||||
- name: Request Postment Echo POST with Unescaped Newline
|
||||
- name: Request Postman Echo POST with Unescaped Newline
|
||||
uses: ./
|
||||
with:
|
||||
url: 'https://postman-echo.com/post'
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
text"
|
||||
}
|
||||
|
||||
- name: Request Postment Echo BasicAuth
|
||||
- name: Request Postman Echo BasicAuth
|
||||
uses: ./
|
||||
with:
|
||||
url: 'https://postman-echo.com/basic-auth'
|
||||
@@ -43,12 +43,18 @@ jobs:
|
||||
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
|
||||
id: image
|
||||
run: |
|
||||
echo "test" > testfile.txt
|
||||
|
||||
- name: Request Postment Echo POST Multipart
|
||||
- name: Request Postman Echo POST Multipart
|
||||
uses: ./
|
||||
with:
|
||||
url: 'https://postman-echo.com/post'
|
||||
|
||||
@@ -24,15 +24,16 @@ jobs:
|
||||
|url | Request URL | _required_ Field |
|
||||
|method | Request Method| POST |
|
||||
|contentType | Request ContentType| application/json |
|
||||
|data | Request Body Content as JSON String, only for POST / PUT / PATCH Requests | '{}' |
|
||||
|data | Request Body Content:<br>- text content like JSON or XML<br>- key=value pairs separated by '&' and contentType: application/x-www-form-urlencoded<br><br>only for POST / PUT / PATCH Requests | '{}' |
|
||||
|files | Map of key / absolute file paths send as multipart/form-data request to the API, if set the contentType is set to multipart/form-data, values provided by data will be added as additional FormData values, nested objects are not supported. **Example provided in the _test_ Workflow of this Action** | '{}' |
|
||||
|timeout| Request Timeout in ms | 5000 (5s) |
|
||||
|username| Username for Basic Auth ||
|
||||
|password| Password for Basic Auth ||
|
||||
|bearerToken| Bearer Authentication Token (without Bearer Prefix) ||
|
||||
|customHeaders| Additional header values as JSON string, keys in this object overwrite default headers like Content-Type |'{}'|
|
||||
|preventFailureOnNoResponse| Prevent this Action to fail if the request respond without an response. Use 'true' (string) as value to enable it ||
|
||||
|escapeData| Escape newlines in data string content. Use 'true' (string) as value to enable it ||
|
||||
|preventFailureOnNoResponse| Prevent this Action to fail if the request respond without an response. Use 'true' (string) as value to enable it ||
|
||||
|ignoreStatusCodes| Prevent this Action to fail if the request respond with one of the configured Status Codes. Example: '404,401' ||
|
||||
|
||||
### Response
|
||||
|
||||
@@ -59,4 +60,4 @@ Additional information is available if debug logging is enabled:
|
||||
- Instance Configuration (Url / Timeout / Headers)
|
||||
- Request Data (Body / Auth / Method)
|
||||
|
||||
To [enable debug logging in GitHub Actions](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging) create a secret `ACTIONS_RUNNER_DEBUG` with a value of `true`
|
||||
To [enable debug logging in GitHub Actions](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging) create a secret `ACTIONS_RUNNER_DEBUG` with a value of `true`
|
||||
|
||||
@@ -38,6 +38,9 @@ inputs:
|
||||
preventFailureOnNoResponse:
|
||||
description: 'Prevent this Action to fail if the request respond without an response'
|
||||
required: false
|
||||
ignoreStatusCodes:
|
||||
description: 'Prevent this Action to fail if the request respond with one of the configured StatusCodes'
|
||||
required: false
|
||||
escapeData:
|
||||
description: 'Escape newlines in data string content'
|
||||
required: false
|
||||
@@ -45,5 +48,5 @@ outputs:
|
||||
response:
|
||||
description: 'HTTP Response Content'
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
|
||||
1935
dist/index.js
vendored
1935
dist/index.js
vendored
File diff suppressed because one or more lines are too long
198
package-lock.json
generated
198
package-lock.json
generated
@@ -1,14 +1,160 @@
|
||||
{
|
||||
"name": "http-request-action",
|
||||
"version": "1.7.3",
|
||||
"lockfileVersion": 1,
|
||||
"version": "1.8.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "http-request-action",
|
||||
"version": "1.8.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@zeit/ncc": "^0.22",
|
||||
"axios": "^0.21.4",
|
||||
"form-data": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@actions/core": "^1.2.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/core": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz",
|
||||
"integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@actions/http-client": "^1.0.11"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/http-client": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
||||
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"tunnel": "0.0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@zeit/ncc": {
|
||||
"version": "0.22.3",
|
||||
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.3.tgz",
|
||||
"integrity": "sha512-jnCLpLXWuw/PAiJiVbLjA8WBC0IJQbFeUwF4I9M+23MvIxTxk5pD4Q8byQBSPmHQjz5aBoA7AKAElQxMpjrCLQ==",
|
||||
"deprecated": "@zeit/ncc is no longer maintained. Please use @vercel/ncc instead.",
|
||||
"bin": {
|
||||
"ncc": "dist/ncc/cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "0.21.4",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
|
||||
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.14.0"
|
||||
}
|
||||
},
|
||||
"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==",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.14.7",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz",
|
||||
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"debug": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.51.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz",
|
||||
"integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.34",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz",
|
||||
"integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.51.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/tunnel": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
||||
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==",
|
||||
"dev": true
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.6.0.tgz",
|
||||
"integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@actions/http-client": "^1.0.11"
|
||||
}
|
||||
},
|
||||
"@actions/http-client": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
||||
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"tunnel": "0.0.6"
|
||||
}
|
||||
},
|
||||
"@zeit/ncc": {
|
||||
"version": "0.22.3",
|
||||
@@ -21,11 +167,11 @@
|
||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.21.1",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
|
||||
"integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
|
||||
"version": "0.21.4",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
|
||||
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
|
||||
"requires": {
|
||||
"follow-redirects": "^1.10.0"
|
||||
"follow-redirects": "^1.14.0"
|
||||
}
|
||||
},
|
||||
"combined-stream": {
|
||||
@@ -42,14 +188,14 @@
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.13.1",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.1.tgz",
|
||||
"integrity": "sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg=="
|
||||
"version": "1.14.7",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz",
|
||||
"integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ=="
|
||||
},
|
||||
"form-data": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
|
||||
"integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==",
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"requires": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
@@ -57,17 +203,23 @@
|
||||
}
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.46.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.46.0.tgz",
|
||||
"integrity": "sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ=="
|
||||
"version": "1.51.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz",
|
||||
"integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g=="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.29",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.29.tgz",
|
||||
"integrity": "sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ==",
|
||||
"version": "2.1.34",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz",
|
||||
"integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==",
|
||||
"requires": {
|
||||
"mime-db": "1.46.0"
|
||||
"mime-db": "1.51.0"
|
||||
}
|
||||
},
|
||||
"tunnel": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "http-request-action",
|
||||
"version": "1.7.3",
|
||||
"version": "1.8.2",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"private": false,
|
||||
@@ -23,7 +23,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@zeit/ncc": "^0.22",
|
||||
"axios": "^0.21.1",
|
||||
"form-data": "^3.0.1"
|
||||
"axios": "^0.21.4",
|
||||
"form-data": "^4.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,21 @@ const fs = require('fs')
|
||||
const METHOD_GET = 'GET'
|
||||
const METHOD_POST = 'POST'
|
||||
|
||||
const request = async({ method, instanceConfig, data, files, auth, actions, preventFailureOnNoResponse, escapeData }) => {
|
||||
/**
|
||||
* @param {Object} param0
|
||||
* @param {string} param0.method HTTP Method
|
||||
* @param {{ baseURL: string; timeout: number; headers: { [name: string]: string } }} param0.instanceConfig
|
||||
* @param {string} param0.data Request Body as string, default {}
|
||||
* @param {string} param0.files Map of Request Files (name: absolute path) as JSON String, default: {}
|
||||
* @param {{ username: string; password: string }|undefined} param0.auth Optional HTTP Basic Auth
|
||||
* @param {*} param0.actions
|
||||
* @param {number[]} param0.ignoredCodes Prevent Action to fail if the API response with one of this StatusCodes
|
||||
* @param {boolean} param0.preventFailureOnNoResponse Prevent Action to fail if the API respond without Response
|
||||
* @param {boolean} param0.escapeData Escape unescaped JSON content in data
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
const request = async({ method, instanceConfig, data, files, auth, actions, ignoredCodes, preventFailureOnNoResponse, escapeData }) => {
|
||||
try {
|
||||
if (escapeData) {
|
||||
data = data.replace(/"[^"]*"/g, (match) => {
|
||||
@@ -51,11 +65,13 @@ const request = async({ method, instanceConfig, data, files, auth, actions, prev
|
||||
actions.setOutput('response', JSON.stringify(response.data))
|
||||
} catch (error) {
|
||||
if (error.toJSON) {
|
||||
actions.setOutput(JSON.stringify(error.toJSON()));
|
||||
actions.setOutput('requestError', JSON.stringify(error.toJSON()));
|
||||
}
|
||||
|
||||
if (error.response) {
|
||||
actions.setFailed(JSON.stringify({ code: error.response.code, message: error.response.data }))
|
||||
if (error.response && ignoredCodes.includes(error.response.status)) {
|
||||
actions.warning(JSON.stringify({ code: error.response.status, message: error.response.data }))
|
||||
} else if (error.response) {
|
||||
actions.setFailed(JSON.stringify({ code: error.response.status, message: error.response.data }))
|
||||
} else if (error.request && !preventFailureOnNoResponse) {
|
||||
actions.setFailed(JSON.stringify({ error: "no response received" }));
|
||||
} else if (error.request && preventFailureOnNoResponse) {
|
||||
@@ -66,6 +82,11 @@ const request = async({ method, instanceConfig, data, files, auth, actions, prev
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
*
|
||||
* @returns {Object}
|
||||
*/
|
||||
const convertToJSON = (value) => {
|
||||
try {
|
||||
return JSON.parse(value)
|
||||
@@ -74,6 +95,12 @@ const convertToJSON = (value) => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} data
|
||||
* @param {Object} files
|
||||
*
|
||||
* @returns {FormData}
|
||||
*/
|
||||
const convertToFormData = (data, files) => {
|
||||
formData = new FormData()
|
||||
|
||||
@@ -88,6 +115,13 @@ const convertToFormData = (data, files) => {
|
||||
return formData
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{ baseURL: string; timeout: number; headers: { [name: string]: string } }} instanceConfig
|
||||
* @param {FormData} formData
|
||||
* @param {*} actions
|
||||
*
|
||||
* @returns {{ baseURL: string; timeout: number; headers: { [name: string]: string } }}
|
||||
*/
|
||||
const updateConfig = async (instanceConfig, formData, actions) => {
|
||||
try {
|
||||
const formHeaders = formData.getHeaders()
|
||||
@@ -109,6 +143,11 @@ const updateConfig = async (instanceConfig, formData, actions) => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {FormData} formData
|
||||
*
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
const contentLength = (formData) => new Promise((resolve, reject) => {
|
||||
formData.getLength((err, length) => {
|
||||
if (err) {
|
||||
|
||||
@@ -40,4 +40,11 @@ const method = core.getInput('method') || METHOD_POST;
|
||||
const preventFailureOnNoResponse = core.getInput('preventFailureOnNoResponse') === 'true';
|
||||
const escapeData = core.getInput('escapeData') === 'true';
|
||||
|
||||
request({ data, method, instanceConfig, auth, preventFailureOnNoResponse, escapeData, files, actions: new GithubActions() })
|
||||
const ignoreStatusCodes = core.getInput('ignoreStatusCodes')
|
||||
let ignoredCodes = []
|
||||
|
||||
if (typeof ignoreStatusCodes === 'string' && ignoreStatusCodes.length > 0) {
|
||||
ignoredCodes = ignoreStatusCodes.split(',').map(statusCode => parseInt(statusCode.trim()))
|
||||
}
|
||||
|
||||
request({ data, method, instanceConfig, auth, preventFailureOnNoResponse, escapeData, files, ignoredCodes, actions: new GithubActions() })
|
||||
|
||||
Reference in New Issue
Block a user