Compare commits

...

28 Commits
2.0.1 ... 2.0.2

Author SHA1 Message Date
Joel Male
aed4f319dc 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)
2020-08-29 11:14:52 +10:00
Joel Male
b77b2b8c6d Merge master -> develop 2020-08-29 11:13:52 +10:00
Joel Male
d6634a0027 Merge branch 'master' into develop
# Conflicts:
#	dist/index.js
#	dist/index.js.map
#	dist/main.js
#	dist/main.js.map
#	node_modules/@vercel/ncc/dist/ncc/cli.js.cache
#	node_modules/@vercel/ncc/dist/ncc/index.js.cache
#	node_modules/@vercel/ncc/dist/ncc/loaders/relocate-loader.js.cache
#	node_modules/@vercel/ncc/dist/ncc/loaders/shebang-loader.js.cache
#	src/main.ts
2020-08-29 11:13:20 +10:00
Joel Male
ee5a04db5d Update @types/node from 14.6.0 to 14.6.1 2020-08-29 11:11:10 +10:00
dependabot[bot]
2546cabb9a Bump @types/node from 14.6.0 to 14.6.1 (#21)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.6.0 to 14.6.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-29 11:10:25 +10:00
Joel Male
144f9e1d68 v2.0.2 2020-08-29 11:10:10 +10:00
Anand Chowdhary
aff8b23be8 Add support for failing check on HTTP error responses (#23) 2020-08-29 11:06:49 +10:00
Joel Male
0c4ba5b174 Add backwards compatibility 2020-08-27 18:25:12 +10:00
Joel Male
01d242f5b1 v2.0.1 2020-08-27 18:23:33 +10:00
dependabot[bot]
9fa1db0dd2 ⬆️ Bump typescript from 3.9.7 to 4.0.2 (#13)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.9.7 to 4.0.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v3.9.7...v4.0.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joel Male <joel@joelmale.com>
2020-08-27 18:15:57 +10:00
dependabot[bot]
ebddbc5b50 Bump prettier from 2.0.5 to 2.1.1 (#15)
Bumps [prettier](https://github.com/prettier/prettier) from 2.0.5 to 2.1.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.0.5...2.1.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-27 18:15:09 +10:00
dependabot[bot]
f91ad44035 Bump @vercel/ncc from 0.23.0 to 0.24.0 (#16)
Bumps [@vercel/ncc](https://github.com/vercel/ncc) from 0.23.0 to 0.24.0.
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](https://github.com/vercel/ncc/compare/0.23.0...0.24.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-27 18:14:56 +10:00
dependabot[bot]
1d93074b53 Bump @actions/core from 1.2.4 to 1.2.5 (#18)
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.4 to 1.2.5.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-27 18:14:42 +10:00
Anand Chowdhary
517289c047 Add support for environment variables (fixed #17) (#19)
* v2.0.0 (#12)

- Convert project to Javascript/Typescript
- Allow custom headers to be passed in (optional)
- Allow body to be optional

* Update action.yml

* Update action.yml

* Add support for environment variables (fixed #17)

* Add support for header as environment variables

* Run build and package

Co-authored-by: Joel Male <joel@joelmale.com>
2020-08-27 18:14:30 +10:00
Joel Male
e22e83d67d Merge branch 'master' into develop
# Conflicts:
#	action.yml
2020-08-27 18:11:32 +10:00
Joel Male
a2d3f9a4da v2.0.0 2020-08-26 10:50:05 +10:00
Joel Male
d3ff660fa9 Allow optional headers & body 2020-08-26 10:41:58 +10:00
Joel Male
5be5ae3f9a Prepare for release
- Final cleanup
2020-08-26 10:38:11 +10:00
Joel Male
db36b9f178 Attempt to have code wait for request to finish 2020-08-26 10:34:42 +10:00
Joel Male
cfebc00721 Attempt to fix missing status code output 2020-08-26 10:31:06 +10:00
Joel Male
d4413d8be7 Update logging for debug purposes 2020-08-26 10:25:43 +10:00
Joel Male
a2c63f8d08 Fix issue with res.status being undefined 2020-08-26 10:20:01 +10:00
Joel Male
0740593bc2 Update build 2020-08-26 10:12:31 +10:00
Joel Male
f43e86409d Remove fetch, add axios 2020-08-26 10:10:43 +10:00
Joel Male
1cbd7b0bbc Add node-fetch 2020-08-26 10:00:45 +10:00
Joel Male
e4e62ab7e8 Add node_modules until bundler is added 2020-08-26 09:57:08 +10:00
Joel Male
600d4f061c Small fixes to action.yml and action output 2020-08-26 09:50:21 +10:00
Joel Male
00f958821e Convert action to ts
- Add optional header support
- Add optional body support
2020-08-26 09:36:04 +10:00
14 changed files with 66 additions and 45 deletions

11
dist/index.js vendored
View File

@@ -91,23 +91,30 @@ function run() {
body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
if (!url) {
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.debug((new Date()).toTimeString());
http_1.http.make(url, headers, body)
.then(function (res) {
if (res.status >= 400) {
error(res.status);
}
core.setOutput('statusCode', res.status);
core.info("Received status code: " + res.status);
core.info((new Date()).toTimeString());
})
.catch(function (err) {
core.setFailed("Received status code: " + err.status);
error(err.status);
});
return [2];
});
});
}
function error(statusCode) {
core.setFailed("Received status code: " + statusCode);
throw new Error("Request failed with status code: " + statusCode);
}
run();
//# sourceMappingURL=main.js.map

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

11
dist/main.js vendored
View File

@@ -47,22 +47,29 @@ function run() {
body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
if (!url) {
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.debug((new Date()).toTimeString());
http_1.http.make(url, headers, body)
.then(function (res) {
if (res.status >= 400) {
error(res.status);
}
core.setOutput('statusCode', res.status);
core.info("Received status code: " + res.status);
core.info((new Date()).toTimeString());
})
.catch(function (err) {
core.setFailed("Received status code: " + err.status);
error(err.status);
});
return [2];
});
});
}
function error(statusCode) {
core.setFailed("Received status code: " + statusCode);
throw new Error("Request failed with status code: " + statusCode);
}
run();
//# sourceMappingURL=main.js.map

2
dist/main.js.map vendored
View File

@@ -1 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsC;AACtC,+BAA8B;AAE9B,SAAe,GAAG;;;;YACR,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC7G,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,G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C,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
View File

@@ -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.
### Additional Details
* Last updated: Mon, 17 Aug 2020 14:33:28 GMT
* Last updated: Thu, 27 Aug 2020 11:19:52 GMT
* Dependencies: none
* Global values: `Buffer`, `Symbol`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`

View File

@@ -152,8 +152,7 @@ declare module "async_hooks" {
/**
* This method disables the instance of `AsyncLocalStorage`. All subsequent calls
* to `asyncLocalStorage.getStore()` will return `undefined` until
* `asyncLocalStorage.run()` or `asyncLocalStorage.runSyncAndReturn()`
* is called again.
* `asyncLocalStorage.run()` is called again.
*
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
* instance will be exited.
@@ -169,45 +168,40 @@ declare module "async_hooks" {
disable(): void;
/**
* This method returns the current store.
* If this method is called outside of an asynchronous context initialized by
* calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will
* This method returns the current store. If this method is called outside of an
* asynchronous context initialized by calling `asyncLocalStorage.run`, it will
* return `undefined`.
*/
getStore(): T | undefined;
/**
* Calling `asyncLocalStorage.run(callback)` will create a new asynchronous
* context.
* Within the callback function and the asynchronous operations from the callback,
* `asyncLocalStorage.getStore()` will return an instance of `Map` known as
* "the store". This store will be persistent through the following
* asynchronous calls.
* This methods runs a function synchronously within a context and return its
* return value. The store is not accessible outside of the callback function or
* the asynchronous operations created within the callback.
*
* The callback will be ran asynchronously. Optionally, arguments can be passed
* to the function. They will be passed to the callback function.
* Optionally, arguments can be passed to the function. They will be passed to the
* callback function.
*
* If an error is thrown by the callback function, it will not be caught by
* a `try/catch` block as the callback is ran in a new asynchronous resource.
* Also, the stacktrace will be impacted by the asynchronous call.
* I the callback function throws an error, it will be thrown by `run` too. The
* stacktrace will not be impacted by this call and the context will be exited.
*/
// 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
* context.
* Within the callback function and the asynchronous operations from the callback,
* `asyncLocalStorage.getStore()` will return `undefined`.
* This methods runs a function synchronously outside of a context and return its
* return value. The store is not accessible within the callback function or the
* asynchronous operations created within the callback.
*
* The callback will be ran asynchronously. Optionally, arguments can be passed
* to the function. They will be passed to the callback function.
* Optionally, arguments can be passed to the function. They will be passed to the
* callback function.
*
* If an error is thrown by the callback function, it will not be caught by
* a `try/catch` block as the callback is ran in a new asynchronous resource.
* Also, the stacktrace will be impacted by the asynchronous call.
* If the callback function throws an error, it will be thrown by `exit` too. The
* stacktrace will not be impacted by this call and the context will be
* 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

View File

@@ -1,6 +1,6 @@
{
"name": "@types/node",
"version": "14.6.0",
"version": "14.6.1",
"description": "TypeScript definitions for Node.js",
"license": "MIT",
"contributors": [
@@ -246,6 +246,6 @@
},
"scripts": {},
"dependencies": {},
"typesPublisherContentHash": "9d0f004e6461e52f8fa5badd6efa10f2dc7d2156363fcb7ca879e15a611c96f0",
"typeScriptVersion": "3.0"
"typesPublisherContentHash": "fe5126c321b3e11256e7d89d506db0a8f78bc70c6d89968a6084e20c9be0acc5",
"typeScriptVersion": "3.1"
}

Binary file not shown.

Binary file not shown.

View File

@@ -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",

View File

@@ -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
@@ -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
@@ -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();

View File

@@ -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"