Skip to content

Commit

Permalink
v2.0.2
Browse files Browse the repository at this point in the history
- Add support for failing check on HTTP error responses (#23) (@AnandChowdhary)
- Bump @types/node from 14.6.0 to 14.6.1 (#21)
  • Loading branch information
joelwmale authored Aug 29, 2020
2 parents cf3a34a + b77b2b8 commit aed4f31
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 45 deletions.
11 changes: 9 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions dist/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/main.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@types/node/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 21 additions & 27 deletions node_modules/@types/node/async_hooks.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions node_modules/@types/node/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified node_modules/@vercel/ncc/dist/ncc/cli.js.cache
Binary file not shown.
Binary file modified node_modules/@vercel/ncc/dist/ncc/index.js.cache
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"devDependencies": {
"@types/jest": "^26.0.10",
"@types/node": "^14.6.0",
"@types/node": "^14.6.1",
"@typescript-eslint/parser": "^3.9.1",
"@vercel/ncc": "^0.24.0",
"eslint": "^7.5.0",
Expand Down
19 changes: 16 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ async function run() {
if (!url) {
// validate a url
core.setFailed('A url is required to run this action.');
return;
// error
throw new Error('A url is required to run this action.');
}

// initial info
Expand All @@ -21,6 +22,12 @@ async function run() {
// make the request
http.make(url, headers, body)
.then((res) => {
// if the status code is not 2xx
if (res.status >= 400) {
// throw an error
error(res.status);
}

// output the status
core.setOutput('statusCode', res.status);
// report on the status code
Expand All @@ -29,9 +36,15 @@ async function run() {
core.info((new Date()).toTimeString());
})
.catch((err) => {
// set the action to failed
core.setFailed(`Received status code: ${err.status}`);
error(err.status);
});
}

function error(statusCode) {
// set the action to failed
core.setFailed(`Received status code: ${statusCode}`);
// throw an error
throw new Error(`Request failed with status code: ${statusCode}`);
}

run();
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=

"@types/node@^14.6.0":
version "14.6.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.0.tgz#7d4411bf5157339337d7cff864d9ff45f177b499"
integrity sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA==
"@types/node@^14.6.1":
version "14.6.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.1.tgz#fdf6f6c6c73d3d8eee9c98a9a0485bc524b048d7"
integrity sha512-HnYlg/BRF8uC1FyKRFZwRaCPTPYKa+6I8QiUZFLredaGOou481cgFS4wKRFyKvQtX8xudqkSdBczJHIYSQYKrQ==

"@types/yargs-parser@*":
version "15.0.0"
Expand Down

0 comments on commit aed4f31

Please sign in to comment.