mirror of
https://github.com/joelwmale/webhook-action.git
synced 2026-09-02 18:56:15 +08:00
v2.1.0
This commit is contained in:
Vendored
+7
-4
@@ -2,17 +2,17 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.http = void 0;
|
||||
var fetch = require('node-fetch');
|
||||
var https = require('https');
|
||||
var Http = (function () {
|
||||
function Http() {
|
||||
}
|
||||
Http.prototype.make = function (url, headers, body) {
|
||||
Http.prototype.make = function (url, headers, body, ignoreCertificate) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
fetch(url, _this.getOptions('post', headers, body))
|
||||
.then(function (res) { return resolve(res); });
|
||||
fetch(url, _this.getOptions('post', headers, body, ignoreCertificate)).then(function (res) { return resolve(res); });
|
||||
});
|
||||
};
|
||||
Http.prototype.getOptions = function (method, headers, body) {
|
||||
Http.prototype.getOptions = function (method, headers, body, ignoreCertificate) {
|
||||
var options = {
|
||||
headers: headers ? JSON.parse(headers) : {},
|
||||
method: method
|
||||
@@ -20,6 +20,9 @@ var Http = (function () {
|
||||
if (body) {
|
||||
options.body = body;
|
||||
}
|
||||
if (ignoreCertificate) {
|
||||
options.agent = new https.Agent({ rejectUnauthorized: false });
|
||||
}
|
||||
options.headers['content-type'] = 'application/json';
|
||||
return options;
|
||||
};
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;AAAA,IAAM,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEpC;IAAA;IAwBA,CAAC;IAvBC,mBAAI,GAAJ,UAAK,GAAW,EAAE,OAAoB,EAAE,IAAiB;QAAzD,iBAKC;QAJC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,KAAK,CAAC,GAAG,EAAE,KAAI,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;iBAC/C,IAAI,C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AEjC,IAAM,OAAO,GAAQ;YACnB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;YAC3C,MAAM,QAAA;SACP,CAAA;QAED,IAAI,IAAI,EAAE;YAER,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;SACpB;QAED,IAAI,iBAAiB,EAAE;YAErB,OAAO,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,EAAC,kBAAkB,EAAE,KAAK,EAAC,CAAC,CAAA;SAC7D;QAGD,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAA;QAEpD,OAAO,OAAO,CAAA;IAChB,CAAC;IACH,WAAC;AAAD,CAAC,AAzCD,IAyCC;AAEY,QAAA,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA"}
|
||||
Vendored
+164
-61
@@ -3,24 +3,24 @@ require('./sourcemap-register.js');module.exports =
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ 319:
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.http = void 0;
|
||||
var fetch = __webpack_require__(467);
|
||||
var fetch = __nccwpck_require__(467);
|
||||
var https = __nccwpck_require__(211);
|
||||
var Http = (function () {
|
||||
function Http() {
|
||||
}
|
||||
Http.prototype.make = function (url, headers, body) {
|
||||
Http.prototype.make = function (url, headers, body, ignoreCertificate) {
|
||||
var _this = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
fetch(url, _this.getOptions('post', headers, body))
|
||||
.then(function (res) { return resolve(res); });
|
||||
fetch(url, _this.getOptions('post', headers, body, ignoreCertificate)).then(function (res) { return resolve(res); });
|
||||
});
|
||||
};
|
||||
Http.prototype.getOptions = function (method, headers, body) {
|
||||
Http.prototype.getOptions = function (method, headers, body, ignoreCertificate) {
|
||||
var options = {
|
||||
headers: headers ? JSON.parse(headers) : {},
|
||||
method: method
|
||||
@@ -28,6 +28,9 @@ var Http = (function () {
|
||||
if (body) {
|
||||
options.body = body;
|
||||
}
|
||||
if (ignoreCertificate) {
|
||||
options.agent = new https.Agent({ rejectUnauthorized: false });
|
||||
}
|
||||
options.headers['content-type'] = 'application/json';
|
||||
return options;
|
||||
};
|
||||
@@ -39,7 +42,7 @@ exports.http = new Http();
|
||||
/***/ }),
|
||||
|
||||
/***/ 496:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -80,32 +83,52 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
var core = __webpack_require__(186);
|
||||
var http_1 = __webpack_require__(319);
|
||||
var core = __nccwpck_require__(186);
|
||||
var http_1 = __nccwpck_require__(319);
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var url, headers, body;
|
||||
var url, headers, body, insecure;
|
||||
return __generator(this, function (_a) {
|
||||
url = core.getInput('url') ? core.getInput('url') : (process.env.WEBHOOK_URL ? process.env.WEBHOOK_URL : '');
|
||||
headers = core.getInput('headers') ? core.getInput('headers') : (process.env.headers ? process.env.headers : null);
|
||||
body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
|
||||
url = core.getInput('url')
|
||||
? core.getInput('url')
|
||||
: process.env.WEBHOOK_URL
|
||||
? process.env.WEBHOOK_URL
|
||||
: '';
|
||||
headers = core.getInput('headers')
|
||||
? core.getInput('headers')
|
||||
: process.env.headers
|
||||
? process.env.headers
|
||||
: null;
|
||||
body = core.getInput('body')
|
||||
? core.getInput('body')
|
||||
: process.env.data
|
||||
? process.env.data
|
||||
: null;
|
||||
insecure = core.getInput('insecure')
|
||||
? core.getInput('insecure') == 'true'
|
||||
: process.env.insecure
|
||||
? process.env.insecure == 'true'
|
||||
: false;
|
||||
if (!url) {
|
||||
core.setFailed('A url is required to run this action.');
|
||||
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)
|
||||
core.debug(new Date().toTimeString());
|
||||
http_1.http
|
||||
.make(url, headers, body, insecure)
|
||||
.then(function (res) {
|
||||
if (res.status >= 400) {
|
||||
error(res.status);
|
||||
return;
|
||||
}
|
||||
core.setOutput('statusCode', res.status);
|
||||
core.info("Received status code: " + res.status);
|
||||
core.info((new Date()).toTimeString());
|
||||
core.info(new Date().toTimeString());
|
||||
})
|
||||
.catch(function (err) {
|
||||
error(err.status);
|
||||
return;
|
||||
});
|
||||
return [2];
|
||||
});
|
||||
@@ -121,7 +144,7 @@ run();
|
||||
/***/ }),
|
||||
|
||||
/***/ 351:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -133,7 +156,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const os = __importStar(__webpack_require__(87));
|
||||
const os = __importStar(__nccwpck_require__(87));
|
||||
const utils_1 = __nccwpck_require__(278);
|
||||
/**
|
||||
* Commands
|
||||
*
|
||||
@@ -187,28 +211,14 @@ class Command {
|
||||
return cmdStr;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||
* @param input input to sanitize into a string
|
||||
*/
|
||||
function toCommandValue(input) {
|
||||
if (input === null || input === undefined) {
|
||||
return '';
|
||||
}
|
||||
else if (typeof input === 'string' || input instanceof String) {
|
||||
return input;
|
||||
}
|
||||
return JSON.stringify(input);
|
||||
}
|
||||
exports.toCommandValue = toCommandValue;
|
||||
function escapeData(s) {
|
||||
return toCommandValue(s)
|
||||
return utils_1.toCommandValue(s)
|
||||
.replace(/%/g, '%25')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A');
|
||||
}
|
||||
function escapeProperty(s) {
|
||||
return toCommandValue(s)
|
||||
return utils_1.toCommandValue(s)
|
||||
.replace(/%/g, '%25')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A')
|
||||
@@ -220,7 +230,7 @@ function escapeProperty(s) {
|
||||
/***/ }),
|
||||
|
||||
/***/ 186:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -241,9 +251,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const command_1 = __webpack_require__(351);
|
||||
const os = __importStar(__webpack_require__(87));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const command_1 = __nccwpck_require__(351);
|
||||
const file_command_1 = __nccwpck_require__(717);
|
||||
const utils_1 = __nccwpck_require__(278);
|
||||
const os = __importStar(__nccwpck_require__(87));
|
||||
const path = __importStar(__nccwpck_require__(622));
|
||||
/**
|
||||
* The code to exit an action
|
||||
*/
|
||||
@@ -268,9 +280,17 @@ var ExitCode;
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function exportVariable(name, val) {
|
||||
const convertedVal = command_1.toCommandValue(val);
|
||||
const convertedVal = utils_1.toCommandValue(val);
|
||||
process.env[name] = convertedVal;
|
||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||
const filePath = process.env['GITHUB_ENV'] || '';
|
||||
if (filePath) {
|
||||
const delimiter = '_GitHubActionsFileCommandDelimeter_';
|
||||
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
||||
file_command_1.issueCommand('ENV', commandValue);
|
||||
}
|
||||
else {
|
||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||
}
|
||||
}
|
||||
exports.exportVariable = exportVariable;
|
||||
/**
|
||||
@@ -286,7 +306,13 @@ exports.setSecret = setSecret;
|
||||
* @param inputPath
|
||||
*/
|
||||
function addPath(inputPath) {
|
||||
command_1.issueCommand('add-path', {}, inputPath);
|
||||
const filePath = process.env['GITHUB_PATH'] || '';
|
||||
if (filePath) {
|
||||
file_command_1.issueCommand('PATH', inputPath);
|
||||
}
|
||||
else {
|
||||
command_1.issueCommand('add-path', {}, inputPath);
|
||||
}
|
||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
||||
}
|
||||
exports.addPath = addPath;
|
||||
@@ -448,8 +474,70 @@ exports.getState = getState;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 717:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// For internal use, subject to change.
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
// We use any as a valid input type
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
const fs = __importStar(__nccwpck_require__(747));
|
||||
const os = __importStar(__nccwpck_require__(87));
|
||||
const utils_1 = __nccwpck_require__(278);
|
||||
function issueCommand(command, message) {
|
||||
const filePath = process.env[`GITHUB_${command}`];
|
||||
if (!filePath) {
|
||||
throw new Error(`Unable to find environment variable for file command ${command}`);
|
||||
}
|
||||
if (!fs.existsSync(filePath)) {
|
||||
throw new Error(`Missing file at path: ${filePath}`);
|
||||
}
|
||||
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
}
|
||||
exports.issueCommand = issueCommand;
|
||||
//# sourceMappingURL=file-command.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 278:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
// We use any as a valid input type
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
/**
|
||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||
* @param input input to sanitize into a string
|
||||
*/
|
||||
function toCommandValue(input) {
|
||||
if (input === null || input === undefined) {
|
||||
return '';
|
||||
}
|
||||
else if (typeof input === 'string' || input instanceof String) {
|
||||
return input;
|
||||
}
|
||||
return JSON.stringify(input);
|
||||
}
|
||||
exports.toCommandValue = toCommandValue;
|
||||
//# sourceMappingURL=utils.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 467:
|
||||
/***/ ((module, exports, __webpack_require__) => {
|
||||
/***/ ((module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -458,11 +546,11 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var Stream = _interopDefault(__webpack_require__(413));
|
||||
var http = _interopDefault(__webpack_require__(605));
|
||||
var Url = _interopDefault(__webpack_require__(835));
|
||||
var https = _interopDefault(__webpack_require__(211));
|
||||
var zlib = _interopDefault(__webpack_require__(761));
|
||||
var Stream = _interopDefault(__nccwpck_require__(413));
|
||||
var http = _interopDefault(__nccwpck_require__(605));
|
||||
var Url = _interopDefault(__nccwpck_require__(835));
|
||||
var https = _interopDefault(__nccwpck_require__(211));
|
||||
var zlib = _interopDefault(__nccwpck_require__(761));
|
||||
|
||||
// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js
|
||||
|
||||
@@ -613,7 +701,7 @@ FetchError.prototype.name = 'FetchError';
|
||||
|
||||
let convert;
|
||||
try {
|
||||
convert = __webpack_require__(877).convert;
|
||||
convert = __nccwpck_require__(877).convert;
|
||||
} catch (e) {}
|
||||
|
||||
const INTERNALS = Symbol('Body internals');
|
||||
@@ -919,6 +1007,12 @@ function convertBody(buffer, headers) {
|
||||
// html4
|
||||
if (!res && str) {
|
||||
res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
|
||||
if (!res) {
|
||||
res = /<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(str);
|
||||
if (res) {
|
||||
res.pop(); // drop last quote
|
||||
}
|
||||
}
|
||||
|
||||
if (res) {
|
||||
res = /charset=(.*)/i.exec(res.pop());
|
||||
@@ -1926,7 +2020,7 @@ function fetch(url, opts) {
|
||||
// HTTP fetch step 5.5
|
||||
switch (request.redirect) {
|
||||
case 'error':
|
||||
reject(new FetchError(`redirect mode is set to error: ${request.url}`, 'no-redirect'));
|
||||
reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));
|
||||
finalize();
|
||||
return;
|
||||
case 'manual':
|
||||
@@ -1965,7 +2059,8 @@ function fetch(url, opts) {
|
||||
method: request.method,
|
||||
body: request.body,
|
||||
signal: request.signal,
|
||||
timeout: request.timeout
|
||||
timeout: request.timeout,
|
||||
size: request.size
|
||||
};
|
||||
|
||||
// HTTP-redirect fetch step 9
|
||||
@@ -2104,13 +2199,21 @@ exports.FetchError = FetchError;
|
||||
module.exports = eval("require")("encoding");
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 747:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("fs");;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 605:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("http");
|
||||
module.exports = require("http");;
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -2118,7 +2221,7 @@ module.exports = require("http");
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("https");
|
||||
module.exports = require("https");;
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -2126,7 +2229,7 @@ module.exports = require("https");
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("os");
|
||||
module.exports = require("os");;
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -2134,7 +2237,7 @@ module.exports = require("os");
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("path");
|
||||
module.exports = require("path");;
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -2142,7 +2245,7 @@ module.exports = require("path");
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("stream");
|
||||
module.exports = require("stream");;
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -2150,7 +2253,7 @@ module.exports = require("stream");
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("url");
|
||||
module.exports = require("url");;
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -2158,7 +2261,7 @@ module.exports = require("url");
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = require("zlib");
|
||||
module.exports = require("zlib");;
|
||||
|
||||
/***/ })
|
||||
|
||||
@@ -2168,7 +2271,7 @@ module.exports = require("zlib");
|
||||
/******/ var __webpack_module_cache__ = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/ function __nccwpck_require__(moduleId) {
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(__webpack_module_cache__[moduleId]) {
|
||||
/******/ return __webpack_module_cache__[moduleId].exports;
|
||||
@@ -2183,7 +2286,7 @@ module.exports = require("zlib");
|
||||
/******/ // Execute the module function
|
||||
/******/ var threw = true;
|
||||
/******/ try {
|
||||
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require__);
|
||||
/******/ threw = false;
|
||||
/******/ } finally {
|
||||
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
||||
@@ -2196,11 +2299,11 @@ module.exports = require("zlib");
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat */
|
||||
/******/
|
||||
/******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/
|
||||
/******/ __nccwpck_require__.ab = __dirname + "/";/************************************************************************/
|
||||
/******/ // module exports must be returned from runtime so entry inlining is disabled
|
||||
/******/ // startup
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(496);
|
||||
/******/ return __nccwpck_require__(496);
|
||||
/******/ })()
|
||||
;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+27
-7
@@ -40,28 +40,48 @@ var core = require("@actions/core");
|
||||
var http_1 = require("./http");
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var url, headers, body;
|
||||
var url, headers, body, insecure;
|
||||
return __generator(this, function (_a) {
|
||||
url = core.getInput('url') ? core.getInput('url') : (process.env.WEBHOOK_URL ? process.env.WEBHOOK_URL : '');
|
||||
headers = core.getInput('headers') ? core.getInput('headers') : (process.env.headers ? process.env.headers : null);
|
||||
body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
|
||||
url = core.getInput('url')
|
||||
? core.getInput('url')
|
||||
: process.env.WEBHOOK_URL
|
||||
? process.env.WEBHOOK_URL
|
||||
: '';
|
||||
headers = core.getInput('headers')
|
||||
? core.getInput('headers')
|
||||
: process.env.headers
|
||||
? process.env.headers
|
||||
: null;
|
||||
body = core.getInput('body')
|
||||
? core.getInput('body')
|
||||
: process.env.data
|
||||
? process.env.data
|
||||
: null;
|
||||
insecure = core.getInput('insecure')
|
||||
? core.getInput('insecure') == 'true'
|
||||
: process.env.insecure
|
||||
? process.env.insecure == 'true'
|
||||
: false;
|
||||
if (!url) {
|
||||
core.setFailed('A url is required to run this action.');
|
||||
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)
|
||||
core.debug(new Date().toTimeString());
|
||||
http_1.http
|
||||
.make(url, headers, body, insecure)
|
||||
.then(function (res) {
|
||||
if (res.status >= 400) {
|
||||
error(res.status);
|
||||
return;
|
||||
}
|
||||
core.setOutput('statusCode', res.status);
|
||||
core.info("Received status code: " + res.status);
|
||||
core.info((new Date()).toTimeString());
|
||||
core.info(new Date().toTimeString());
|
||||
})
|
||||
.catch(function (err) {
|
||||
error(err.status);
|
||||
return;
|
||||
});
|
||||
return [2];
|
||||
});
|
||||
|
||||
Vendored
+1
-1
@@ -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,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lines are too long
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "webhook-action",
|
||||
"version": "2.0.2",
|
||||
"version": "2.1.0",
|
||||
"description": "Github Webhook Action",
|
||||
"main": "dist/main.js",
|
||||
"scripts": {
|
||||
|
||||
+25
-13
@@ -1,35 +1,47 @@
|
||||
const fetch = require('node-fetch');
|
||||
var https = require('https');
|
||||
const fetch = require('node-fetch')
|
||||
var https = require('https')
|
||||
|
||||
class Http {
|
||||
make(url: string, headers: string | null, body: string | null, ignoreCertificate: boolean | null): Promise<any> {
|
||||
make(
|
||||
url: string,
|
||||
headers: string | null,
|
||||
body: string | null,
|
||||
ignoreCertificate: boolean | null
|
||||
): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(url, this.getOptions('post', headers, body, ignoreCertificate))
|
||||
.then((res: Response) => resolve(res));
|
||||
});
|
||||
fetch(
|
||||
url,
|
||||
this.getOptions('post', headers, body, ignoreCertificate)
|
||||
).then((res: Response) => resolve(res))
|
||||
})
|
||||
}
|
||||
|
||||
getOptions(method: string, headers: string | null, body: string | null, ignoreCertificate: boolean | null) {
|
||||
getOptions(
|
||||
method: string,
|
||||
headers: string | null,
|
||||
body: string | null,
|
||||
ignoreCertificate: boolean | null
|
||||
) {
|
||||
const options: any = {
|
||||
headers: headers ? JSON.parse(headers) : {},
|
||||
method
|
||||
};
|
||||
}
|
||||
|
||||
if (body) {
|
||||
// parse the body
|
||||
options.body = body;
|
||||
options.body = body
|
||||
}
|
||||
|
||||
if (ignoreCertificate) {
|
||||
// ignore the certificate by not rejecting authorized servers
|
||||
options.agent = new https.Agent({ rejectUnauthorized: false });
|
||||
options.agent = new https.Agent({rejectUnauthorized: false})
|
||||
}
|
||||
|
||||
// set these headers
|
||||
options.headers['content-type'] = 'application/json';
|
||||
options.headers['content-type'] = 'application/json'
|
||||
|
||||
return options;
|
||||
return options
|
||||
}
|
||||
}
|
||||
|
||||
export const http = new Http();
|
||||
export const http = new Http()
|
||||
|
||||
+56
-39
@@ -1,53 +1,70 @@
|
||||
import * as core from '@actions/core';
|
||||
import { http } from './http';
|
||||
import * as core from '@actions/core'
|
||||
import {http} from './http'
|
||||
|
||||
async function run() {
|
||||
const url = core.getInput('url') ? core.getInput('url') : (process.env.WEBHOOK_URL ? process.env.WEBHOOK_URL : '');
|
||||
const headers = core.getInput('headers') ? core.getInput('headers') : (process.env.headers ? process.env.headers : null);
|
||||
const body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
|
||||
const insecure = core.getInput('insecure') ? core.getInput('insecure') == 'true' : (process.env.insecure ? process.env.insecure == 'true' : false);
|
||||
const url = core.getInput('url')
|
||||
? core.getInput('url')
|
||||
: process.env.WEBHOOK_URL
|
||||
? process.env.WEBHOOK_URL
|
||||
: ''
|
||||
const headers = core.getInput('headers')
|
||||
? core.getInput('headers')
|
||||
: process.env.headers
|
||||
? process.env.headers
|
||||
: null
|
||||
const body = core.getInput('body')
|
||||
? core.getInput('body')
|
||||
: process.env.data
|
||||
? process.env.data
|
||||
: null
|
||||
const insecure = core.getInput('insecure')
|
||||
? core.getInput('insecure') == 'true'
|
||||
: process.env.insecure
|
||||
? process.env.insecure == 'true'
|
||||
: false
|
||||
|
||||
if (!url) {
|
||||
// validate a url
|
||||
core.setFailed('A url is required to run this action.');
|
||||
// error
|
||||
throw new Error('A url is required to run this action.');
|
||||
}
|
||||
if (!url) {
|
||||
// validate a url
|
||||
core.setFailed('A url is required to run this action.')
|
||||
// error
|
||||
throw new Error('A url is required to run this action.')
|
||||
}
|
||||
|
||||
// initial info
|
||||
core.info(`Sending webhook request to ${url}`);
|
||||
// initial info
|
||||
core.info(`Sending webhook request to ${url}`)
|
||||
|
||||
// debug start
|
||||
core.debug((new Date()).toTimeString()); // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
|
||||
// debug start
|
||||
core.debug(new Date().toTimeString()) // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
|
||||
|
||||
// make the request
|
||||
http.make(url, headers, body, insecure)
|
||||
.then((res) => {
|
||||
// if the status code is not 2xx
|
||||
if (res.status >= 400) {
|
||||
// throw an error
|
||||
error(res.status);
|
||||
return;
|
||||
}
|
||||
// make the request
|
||||
http
|
||||
.make(url, headers, body, insecure)
|
||||
.then(res => {
|
||||
// if the status code is not 2xx
|
||||
if (res.status >= 400) {
|
||||
// throw an error
|
||||
error(res.status)
|
||||
return
|
||||
}
|
||||
|
||||
// output the status
|
||||
core.setOutput('statusCode', res.status);
|
||||
// report on the status code
|
||||
core.info(`Received status code: ${res.status}`);
|
||||
// debug end
|
||||
core.info((new Date()).toTimeString());
|
||||
})
|
||||
.catch((err) => {
|
||||
error(err.status);
|
||||
return;
|
||||
});
|
||||
// output the status
|
||||
core.setOutput('statusCode', res.status)
|
||||
// report on the status code
|
||||
core.info(`Received status code: ${res.status}`)
|
||||
// debug end
|
||||
core.info(new Date().toTimeString())
|
||||
})
|
||||
.catch(err => {
|
||||
error(err.status)
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
function error(statusCode) {
|
||||
// set the action to failed
|
||||
core.setFailed(`Received status code: ${statusCode}`);
|
||||
core.setFailed(`Received status code: ${statusCode}`)
|
||||
// throw an error
|
||||
throw new Error(`Request failed with status code: ${statusCode}`);
|
||||
throw new Error(`Request failed with status code: ${statusCode}`)
|
||||
}
|
||||
|
||||
run();
|
||||
run()
|
||||
|
||||
Reference in New Issue
Block a user