mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-11-29 02:45:23 +01:00
v2.0.2
- Add support for failing check on HTTP error responses (#23) (@AnandChowdhary) - Bump @types/node from 14.6.0 to 14.6.1 (#21)
This commit is contained in:
commit
aed4f319dc
14 changed files with 66 additions and 45 deletions
11
dist/index.js
vendored
11
dist/index.js
vendored
|
@ -91,23 +91,30 @@ function run() {
|
||||||
body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
|
body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
|
||||||
if (!url) {
|
if (!url) {
|
||||||
core.setFailed('A url is required to run this action.');
|
core.setFailed('A url is required to run this action.');
|
||||||
return [2];
|
throw new Error('A url is required to run this action.');
|
||||||
}
|
}
|
||||||
core.info("Sending webhook request to " + url);
|
core.info("Sending webhook request to " + url);
|
||||||
core.debug((new Date()).toTimeString());
|
core.debug((new Date()).toTimeString());
|
||||||
http_1.http.make(url, headers, body)
|
http_1.http.make(url, headers, body)
|
||||||
.then(function (res) {
|
.then(function (res) {
|
||||||
|
if (res.status >= 400) {
|
||||||
|
error(res.status);
|
||||||
|
}
|
||||||
core.setOutput('statusCode', res.status);
|
core.setOutput('statusCode', res.status);
|
||||||
core.info("Received status code: " + res.status);
|
core.info("Received status code: " + res.status);
|
||||||
core.info((new Date()).toTimeString());
|
core.info((new Date()).toTimeString());
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
core.setFailed("Received status code: " + err.status);
|
error(err.status);
|
||||||
});
|
});
|
||||||
return [2];
|
return [2];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function error(statusCode) {
|
||||||
|
core.setFailed("Received status code: " + statusCode);
|
||||||
|
throw new Error("Request failed with status code: " + statusCode);
|
||||||
|
}
|
||||||
run();
|
run();
|
||||||
//# sourceMappingURL=main.js.map
|
//# sourceMappingURL=main.js.map
|
||||||
|
|
||||||
|
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
11
dist/main.js
vendored
11
dist/main.js
vendored
|
@ -47,22 +47,29 @@ function run() {
|
||||||
body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
|
body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
|
||||||
if (!url) {
|
if (!url) {
|
||||||
core.setFailed('A url is required to run this action.');
|
core.setFailed('A url is required to run this action.');
|
||||||
return [2];
|
throw new Error('A url is required to run this action.');
|
||||||
}
|
}
|
||||||
core.info("Sending webhook request to " + url);
|
core.info("Sending webhook request to " + url);
|
||||||
core.debug((new Date()).toTimeString());
|
core.debug((new Date()).toTimeString());
|
||||||
http_1.http.make(url, headers, body)
|
http_1.http.make(url, headers, body)
|
||||||
.then(function (res) {
|
.then(function (res) {
|
||||||
|
if (res.status >= 400) {
|
||||||
|
error(res.status);
|
||||||
|
}
|
||||||
core.setOutput('statusCode', res.status);
|
core.setOutput('statusCode', res.status);
|
||||||
core.info("Received status code: " + res.status);
|
core.info("Received status code: " + res.status);
|
||||||
core.info((new Date()).toTimeString());
|
core.info((new Date()).toTimeString());
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
core.setFailed("Received status code: " + err.status);
|
error(err.status);
|
||||||
});
|
});
|
||||||
return [2];
|
return [2];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function error(statusCode) {
|
||||||
|
core.setFailed("Received status code: " + statusCode);
|
||||||
|
throw new Error("Request failed with status code: " + statusCode);
|
||||||
|
}
|
||||||
run();
|
run();
|
||||||
//# sourceMappingURL=main.js.map
|
//# sourceMappingURL=main.js.map
|
2
dist/main.js.map
vendored
2
dist/main.js.map
vendored
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AACtC,+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,EAAE;gBAER,IAAI,CAAC,SAAS,CAAC,uCAAuC,CAAC,CAAC;gBAExD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;aAC1D;YAGD,IAAI,CAAC,IAAI,CAAC,gCAA8B,GAAK,CAAC,CAAC;YAG/C,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;YAGxC,WAAI,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;iBAC1B,IAAI,CAAC,UAAC,GAAG;gBAER,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE;oBAErB,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBACnB;gBAGD,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;gBAEzC,IAAI,CAAC,IAAI,CAAC,2BAAyB,GAAG,CAAC,MAAQ,CAAC,CAAC;gBAEjD,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;YACzC,CAAC,CAAC;iBACD,KAAK,CAAC,UAAC,GAAG;gBACT,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;;;;CACR;AAED,SAAS,KAAK,CAAC,UAAU;IAEvB,IAAI,CAAC,SAAS,CAAC,2BAAyB,UAAY,CAAC,CAAC;IAEtD,MAAM,IAAI,KAAK,CAAC,sCAAoC,UAAY,CAAC,CAAC;AACpE,CAAC;AAED,GAAG,EAAE,CAAC"}
|
2
node_modules/@types/node/README.md
generated
vendored
2
node_modules/@types/node/README.md
generated
vendored
|
@ -8,7 +8,7 @@ This package contains type definitions for Node.js (http://nodejs.org/).
|
||||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
||||||
|
|
||||||
### Additional Details
|
### Additional Details
|
||||||
* Last updated: Mon, 17 Aug 2020 14:33:28 GMT
|
* Last updated: Thu, 27 Aug 2020 11:19:52 GMT
|
||||||
* Dependencies: none
|
* Dependencies: none
|
||||||
* Global values: `Buffer`, `Symbol`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
|
* Global values: `Buffer`, `Symbol`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
|
||||||
|
|
||||||
|
|
48
node_modules/@types/node/async_hooks.d.ts
generated
vendored
48
node_modules/@types/node/async_hooks.d.ts
generated
vendored
|
@ -152,8 +152,7 @@ declare module "async_hooks" {
|
||||||
/**
|
/**
|
||||||
* This method disables the instance of `AsyncLocalStorage`. All subsequent calls
|
* This method disables the instance of `AsyncLocalStorage`. All subsequent calls
|
||||||
* to `asyncLocalStorage.getStore()` will return `undefined` until
|
* to `asyncLocalStorage.getStore()` will return `undefined` until
|
||||||
* `asyncLocalStorage.run()` or `asyncLocalStorage.runSyncAndReturn()`
|
* `asyncLocalStorage.run()` is called again.
|
||||||
* is called again.
|
|
||||||
*
|
*
|
||||||
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
||||||
* instance will be exited.
|
* instance will be exited.
|
||||||
|
@ -169,45 +168,40 @@ declare module "async_hooks" {
|
||||||
disable(): void;
|
disable(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the current store.
|
* This method returns the current store. If this method is called outside of an
|
||||||
* If this method is called outside of an asynchronous context initialized by
|
* asynchronous context initialized by calling `asyncLocalStorage.run`, it will
|
||||||
* calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will
|
|
||||||
* return `undefined`.
|
* return `undefined`.
|
||||||
*/
|
*/
|
||||||
getStore(): T | undefined;
|
getStore(): T | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calling `asyncLocalStorage.run(callback)` will create a new asynchronous
|
* This methods runs a function synchronously within a context and return its
|
||||||
* context.
|
* return value. The store is not accessible outside of the callback function or
|
||||||
* Within the callback function and the asynchronous operations from the callback,
|
* the asynchronous operations created within the callback.
|
||||||
* `asyncLocalStorage.getStore()` will return an instance of `Map` known as
|
|
||||||
* "the store". This store will be persistent through the following
|
|
||||||
* asynchronous calls.
|
|
||||||
*
|
*
|
||||||
* The callback will be ran asynchronously. Optionally, arguments can be passed
|
* Optionally, arguments can be passed to the function. They will be passed to the
|
||||||
* to the function. They will be passed to the callback function.
|
* callback function.
|
||||||
*
|
*
|
||||||
* If an error is thrown by the callback function, it will not be caught by
|
* I the callback function throws an error, it will be thrown by `run` too. The
|
||||||
* a `try/catch` block as the callback is ran in a new asynchronous resource.
|
* stacktrace will not be impacted by this call and the context will be exited.
|
||||||
* Also, the stacktrace will be impacted by the asynchronous call.
|
|
||||||
*/
|
*/
|
||||||
// TODO: Apply generic vararg once available
|
// TODO: Apply generic vararg once available
|
||||||
run(store: T, callback: (...args: any[]) => void, ...args: any[]): void;
|
run<R>(store: T, callback: (...args: any[]) => R, ...args: any[]): R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous
|
* This methods runs a function synchronously outside of a context and return its
|
||||||
* context.
|
* return value. The store is not accessible within the callback function or the
|
||||||
* Within the callback function and the asynchronous operations from the callback,
|
* asynchronous operations created within the callback.
|
||||||
* `asyncLocalStorage.getStore()` will return `undefined`.
|
|
||||||
*
|
*
|
||||||
* The callback will be ran asynchronously. Optionally, arguments can be passed
|
* Optionally, arguments can be passed to the function. They will be passed to the
|
||||||
* to the function. They will be passed to the callback function.
|
* callback function.
|
||||||
*
|
*
|
||||||
* If an error is thrown by the callback function, it will not be caught by
|
* If the callback function throws an error, it will be thrown by `exit` too. The
|
||||||
* a `try/catch` block as the callback is ran in a new asynchronous resource.
|
* stacktrace will not be impacted by this call and the context will be
|
||||||
* Also, the stacktrace will be impacted by the asynchronous call.
|
* re-entered.
|
||||||
*/
|
*/
|
||||||
exit(callback: (...args: any[]) => void, ...args: any[]): void;
|
// TODO: Apply generic vararg once available
|
||||||
|
exit<R>(callback: (...args: any[]) => R, ...args: any[]): R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calling `asyncLocalStorage.enterWith(store)` will transition into the context
|
* Calling `asyncLocalStorage.enterWith(store)` will transition into the context
|
||||||
|
|
6
node_modules/@types/node/package.json
generated
vendored
6
node_modules/@types/node/package.json
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@types/node",
|
"name": "@types/node",
|
||||||
"version": "14.6.0",
|
"version": "14.6.1",
|
||||||
"description": "TypeScript definitions for Node.js",
|
"description": "TypeScript definitions for Node.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
|
@ -246,6 +246,6 @@
|
||||||
},
|
},
|
||||||
"scripts": {},
|
"scripts": {},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"typesPublisherContentHash": "9d0f004e6461e52f8fa5badd6efa10f2dc7d2156363fcb7ca879e15a611c96f0",
|
"typesPublisherContentHash": "fe5126c321b3e11256e7d89d506db0a8f78bc70c6d89968a6084e20c9be0acc5",
|
||||||
"typeScriptVersion": "3.0"
|
"typeScriptVersion": "3.1"
|
||||||
}
|
}
|
BIN
node_modules/@vercel/ncc/dist/ncc/cli.js.cache
generated
vendored
BIN
node_modules/@vercel/ncc/dist/ncc/cli.js.cache
generated
vendored
Binary file not shown.
BIN
node_modules/@vercel/ncc/dist/ncc/index.js.cache
generated
vendored
BIN
node_modules/@vercel/ncc/dist/ncc/index.js.cache
generated
vendored
Binary file not shown.
BIN
node_modules/@vercel/ncc/dist/ncc/loaders/relocate-loader.js.cache
generated
vendored
BIN
node_modules/@vercel/ncc/dist/ncc/loaders/relocate-loader.js.cache
generated
vendored
Binary file not shown.
BIN
node_modules/@vercel/ncc/dist/ncc/loaders/shebang-loader.js.cache
generated
vendored
BIN
node_modules/@vercel/ncc/dist/ncc/loaders/shebang-loader.js.cache
generated
vendored
Binary file not shown.
|
@ -28,7 +28,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.10",
|
"@types/jest": "^26.0.10",
|
||||||
"@types/node": "^14.6.0",
|
"@types/node": "^14.6.1",
|
||||||
"@typescript-eslint/parser": "^3.9.1",
|
"@typescript-eslint/parser": "^3.9.1",
|
||||||
"@vercel/ncc": "^0.24.0",
|
"@vercel/ncc": "^0.24.0",
|
||||||
"eslint": "^7.5.0",
|
"eslint": "^7.5.0",
|
||||||
|
|
19
src/main.ts
19
src/main.ts
|
@ -9,7 +9,8 @@ async function run() {
|
||||||
if (!url) {
|
if (!url) {
|
||||||
// validate a url
|
// validate a url
|
||||||
core.setFailed('A url is required to run this action.');
|
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
|
// initial info
|
||||||
|
@ -21,6 +22,12 @@ async function run() {
|
||||||
// make the request
|
// make the request
|
||||||
http.make(url, headers, body)
|
http.make(url, headers, body)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
// if the status code is not 2xx
|
||||||
|
if (res.status >= 400) {
|
||||||
|
// throw an error
|
||||||
|
error(res.status);
|
||||||
|
}
|
||||||
|
|
||||||
// output the status
|
// output the status
|
||||||
core.setOutput('statusCode', res.status);
|
core.setOutput('statusCode', res.status);
|
||||||
// report on the status code
|
// report on the status code
|
||||||
|
@ -29,9 +36,15 @@ async function run() {
|
||||||
core.info((new Date()).toTimeString());
|
core.info((new Date()).toTimeString());
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
// set the action to failed
|
error(err.status);
|
||||||
core.setFailed(`Received status code: ${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();
|
run();
|
||||||
|
|
|
@ -86,10 +86,10 @@
|
||||||
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
|
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
|
||||||
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
|
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
|
||||||
|
|
||||||
"@types/node@^14.6.0":
|
"@types/node@^14.6.1":
|
||||||
version "14.6.0"
|
version "14.6.1"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.0.tgz#7d4411bf5157339337d7cff864d9ff45f177b499"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.1.tgz#fdf6f6c6c73d3d8eee9c98a9a0485bc524b048d7"
|
||||||
integrity sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA==
|
integrity sha512-HnYlg/BRF8uC1FyKRFZwRaCPTPYKa+6I8QiUZFLredaGOou481cgFS4wKRFyKvQtX8xudqkSdBczJHIYSQYKrQ==
|
||||||
|
|
||||||
"@types/yargs-parser@*":
|
"@types/yargs-parser@*":
|
||||||
version "15.0.0"
|
version "15.0.0"
|
||||||
|
|
Loading…
Reference in a new issue