mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-08-25 08:08:00 +00:00
v2.1.0
This commit is contained in:
parent
9380ee26ff
commit
6f6298309b
11
dist/http.js
vendored
11
dist/http.js
vendored
@ -2,17 +2,17 @@
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.http = void 0;
|
exports.http = void 0;
|
||||||
var fetch = require('node-fetch');
|
var fetch = require('node-fetch');
|
||||||
|
var https = require('https');
|
||||||
var Http = (function () {
|
var Http = (function () {
|
||||||
function Http() {
|
function Http() {
|
||||||
}
|
}
|
||||||
Http.prototype.make = function (url, headers, body) {
|
Http.prototype.make = function (url, headers, body, ignoreCertificate) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
fetch(url, _this.getOptions('post', headers, body))
|
fetch(url, _this.getOptions('post', headers, body, ignoreCertificate)).then(function (res) { return resolve(res); });
|
||||||
.then(function (res) { return resolve(res); });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Http.prototype.getOptions = function (method, headers, body) {
|
Http.prototype.getOptions = function (method, headers, body, ignoreCertificate) {
|
||||||
var options = {
|
var options = {
|
||||||
headers: headers ? JSON.parse(headers) : {},
|
headers: headers ? JSON.parse(headers) : {},
|
||||||
method: method
|
method: method
|
||||||
@ -20,6 +20,9 @@ var Http = (function () {
|
|||||||
if (body) {
|
if (body) {
|
||||||
options.body = body;
|
options.body = body;
|
||||||
}
|
}
|
||||||
|
if (ignoreCertificate) {
|
||||||
|
options.agent = new https.Agent({ rejectUnauthorized: false });
|
||||||
|
}
|
||||||
options.headers['content-type'] = 'application/json';
|
options.headers['content-type'] = 'application/json';
|
||||||
return options;
|
return options;
|
||||||
};
|
};
|
||||||
|
2
dist/http.js.map
vendored
2
dist/http.js.map
vendored
@ -1 +1 @@
|
|||||||
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.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CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,KAAK,CACH,GAAG,EACH,KAAI,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAC1D,CAAC,IAAI,CAAC,UAAC,GAAa,IAAK,OAAA,OAAO,CAAC,GAAG,CAAC,EAAZ,CAAY,CAAC,CAAA;QACzC,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,yBAAU,GAAV,UACE,MAAc,EACd,OAAsB,EACtB,IAAmB,EACnB,iBAAiC;QAEjC,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"}
|
221
dist/index.js
vendored
221
dist/index.js
vendored
@ -3,24 +3,24 @@ require('./sourcemap-register.js');module.exports =
|
|||||||
/******/ var __webpack_modules__ = ({
|
/******/ var __webpack_modules__ = ({
|
||||||
|
|
||||||
/***/ 319:
|
/***/ 319:
|
||||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.http = void 0;
|
exports.http = void 0;
|
||||||
var fetch = __webpack_require__(467);
|
var fetch = __nccwpck_require__(467);
|
||||||
|
var https = __nccwpck_require__(211);
|
||||||
var Http = (function () {
|
var Http = (function () {
|
||||||
function Http() {
|
function Http() {
|
||||||
}
|
}
|
||||||
Http.prototype.make = function (url, headers, body) {
|
Http.prototype.make = function (url, headers, body, ignoreCertificate) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
fetch(url, _this.getOptions('post', headers, body))
|
fetch(url, _this.getOptions('post', headers, body, ignoreCertificate)).then(function (res) { return resolve(res); });
|
||||||
.then(function (res) { return resolve(res); });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Http.prototype.getOptions = function (method, headers, body) {
|
Http.prototype.getOptions = function (method, headers, body, ignoreCertificate) {
|
||||||
var options = {
|
var options = {
|
||||||
headers: headers ? JSON.parse(headers) : {},
|
headers: headers ? JSON.parse(headers) : {},
|
||||||
method: method
|
method: method
|
||||||
@ -28,6 +28,9 @@ var Http = (function () {
|
|||||||
if (body) {
|
if (body) {
|
||||||
options.body = body;
|
options.body = body;
|
||||||
}
|
}
|
||||||
|
if (ignoreCertificate) {
|
||||||
|
options.agent = new https.Agent({ rejectUnauthorized: false });
|
||||||
|
}
|
||||||
options.headers['content-type'] = 'application/json';
|
options.headers['content-type'] = 'application/json';
|
||||||
return options;
|
return options;
|
||||||
};
|
};
|
||||||
@ -39,7 +42,7 @@ exports.http = new Http();
|
|||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 496:
|
/***/ 496:
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@ -80,32 +83,52 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
var core = __webpack_require__(186);
|
var core = __nccwpck_require__(186);
|
||||||
var http_1 = __webpack_require__(319);
|
var http_1 = __nccwpck_require__(319);
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
var url, headers, body;
|
var url, headers, body, insecure;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
url = core.getInput('url') ? core.getInput('url') : (process.env.WEBHOOK_URL ? process.env.WEBHOOK_URL : '');
|
url = core.getInput('url')
|
||||||
headers = core.getInput('headers') ? core.getInput('headers') : (process.env.headers ? process.env.headers : null);
|
? core.getInput('url')
|
||||||
body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
|
: 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) {
|
if (!url) {
|
||||||
core.setFailed('A url is required to run this action.');
|
core.setFailed('A url is required to run this action.');
|
||||||
throw new Error('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.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, insecure)
|
||||||
.then(function (res) {
|
.then(function (res) {
|
||||||
if (res.status >= 400) {
|
if (res.status >= 400) {
|
||||||
error(res.status);
|
error(res.status);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
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) {
|
||||||
error(err.status);
|
error(err.status);
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
return [2];
|
return [2];
|
||||||
});
|
});
|
||||||
@ -121,7 +144,7 @@ run();
|
|||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 351:
|
/***/ 351:
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@ -133,7 +156,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
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
|
* Commands
|
||||||
*
|
*
|
||||||
@ -187,28 +211,14 @@ class Command {
|
|||||||
return cmdStr;
|
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) {
|
function escapeData(s) {
|
||||||
return toCommandValue(s)
|
return utils_1.toCommandValue(s)
|
||||||
.replace(/%/g, '%25')
|
.replace(/%/g, '%25')
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A');
|
.replace(/\n/g, '%0A');
|
||||||
}
|
}
|
||||||
function escapeProperty(s) {
|
function escapeProperty(s) {
|
||||||
return toCommandValue(s)
|
return utils_1.toCommandValue(s)
|
||||||
.replace(/%/g, '%25')
|
.replace(/%/g, '%25')
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A')
|
.replace(/\n/g, '%0A')
|
||||||
@ -220,7 +230,7 @@ function escapeProperty(s) {
|
|||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 186:
|
/***/ 186:
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@ -241,9 +251,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const command_1 = __webpack_require__(351);
|
const command_1 = __nccwpck_require__(351);
|
||||||
const os = __importStar(__webpack_require__(87));
|
const file_command_1 = __nccwpck_require__(717);
|
||||||
const path = __importStar(__webpack_require__(622));
|
const utils_1 = __nccwpck_require__(278);
|
||||||
|
const os = __importStar(__nccwpck_require__(87));
|
||||||
|
const path = __importStar(__nccwpck_require__(622));
|
||||||
/**
|
/**
|
||||||
* The code to exit an action
|
* The code to exit an action
|
||||||
*/
|
*/
|
||||||
@ -268,9 +280,17 @@ var ExitCode;
|
|||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function exportVariable(name, val) {
|
function exportVariable(name, val) {
|
||||||
const convertedVal = command_1.toCommandValue(val);
|
const convertedVal = utils_1.toCommandValue(val);
|
||||||
process.env[name] = convertedVal;
|
process.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);
|
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.exportVariable = exportVariable;
|
exports.exportVariable = exportVariable;
|
||||||
/**
|
/**
|
||||||
@ -286,7 +306,13 @@ exports.setSecret = setSecret;
|
|||||||
* @param inputPath
|
* @param inputPath
|
||||||
*/
|
*/
|
||||||
function addPath(inputPath) {
|
function addPath(inputPath) {
|
||||||
|
const filePath = process.env['GITHUB_PATH'] || '';
|
||||||
|
if (filePath) {
|
||||||
|
file_command_1.issueCommand('PATH', inputPath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
command_1.issueCommand('add-path', {}, inputPath);
|
||||||
|
}
|
||||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
||||||
}
|
}
|
||||||
exports.addPath = addPath;
|
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:
|
/***/ 467:
|
||||||
/***/ ((module, exports, __webpack_require__) => {
|
/***/ ((module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
"use strict";
|
"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; }
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||||
|
|
||||||
var Stream = _interopDefault(__webpack_require__(413));
|
var Stream = _interopDefault(__nccwpck_require__(413));
|
||||||
var http = _interopDefault(__webpack_require__(605));
|
var http = _interopDefault(__nccwpck_require__(605));
|
||||||
var Url = _interopDefault(__webpack_require__(835));
|
var Url = _interopDefault(__nccwpck_require__(835));
|
||||||
var https = _interopDefault(__webpack_require__(211));
|
var https = _interopDefault(__nccwpck_require__(211));
|
||||||
var zlib = _interopDefault(__webpack_require__(761));
|
var zlib = _interopDefault(__nccwpck_require__(761));
|
||||||
|
|
||||||
// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js
|
// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js
|
||||||
|
|
||||||
@ -613,7 +701,7 @@ FetchError.prototype.name = 'FetchError';
|
|||||||
|
|
||||||
let convert;
|
let convert;
|
||||||
try {
|
try {
|
||||||
convert = __webpack_require__(877).convert;
|
convert = __nccwpck_require__(877).convert;
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
const INTERNALS = Symbol('Body internals');
|
const INTERNALS = Symbol('Body internals');
|
||||||
@ -919,6 +1007,12 @@ function convertBody(buffer, headers) {
|
|||||||
// html4
|
// html4
|
||||||
if (!res && str) {
|
if (!res && str) {
|
||||||
res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(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) {
|
if (res) {
|
||||||
res = /charset=(.*)/i.exec(res.pop());
|
res = /charset=(.*)/i.exec(res.pop());
|
||||||
@ -1926,7 +2020,7 @@ function fetch(url, opts) {
|
|||||||
// HTTP fetch step 5.5
|
// HTTP fetch step 5.5
|
||||||
switch (request.redirect) {
|
switch (request.redirect) {
|
||||||
case 'error':
|
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();
|
finalize();
|
||||||
return;
|
return;
|
||||||
case 'manual':
|
case 'manual':
|
||||||
@ -1965,7 +2059,8 @@ function fetch(url, opts) {
|
|||||||
method: request.method,
|
method: request.method,
|
||||||
body: request.body,
|
body: request.body,
|
||||||
signal: request.signal,
|
signal: request.signal,
|
||||||
timeout: request.timeout
|
timeout: request.timeout,
|
||||||
|
size: request.size
|
||||||
};
|
};
|
||||||
|
|
||||||
// HTTP-redirect fetch step 9
|
// HTTP-redirect fetch step 9
|
||||||
@ -2104,13 +2199,21 @@ exports.FetchError = FetchError;
|
|||||||
module.exports = eval("require")("encoding");
|
module.exports = eval("require")("encoding");
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 747:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
module.exports = require("fs");;
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 605:
|
/***/ 605:
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports = require("http");
|
module.exports = require("http");;
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@ -2118,7 +2221,7 @@ module.exports = require("http");
|
|||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports = require("https");
|
module.exports = require("https");;
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@ -2126,7 +2229,7 @@ module.exports = require("https");
|
|||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports = require("os");
|
module.exports = require("os");;
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@ -2134,7 +2237,7 @@ module.exports = require("os");
|
|||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports = require("path");
|
module.exports = require("path");;
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@ -2142,7 +2245,7 @@ module.exports = require("path");
|
|||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports = require("stream");
|
module.exports = require("stream");;
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@ -2150,7 +2253,7 @@ module.exports = require("stream");
|
|||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports = require("url");
|
module.exports = require("url");;
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@ -2158,7 +2261,7 @@ module.exports = require("url");
|
|||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
module.exports = require("zlib");
|
module.exports = require("zlib");;
|
||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
|
|
||||||
@ -2168,7 +2271,7 @@ module.exports = require("zlib");
|
|||||||
/******/ var __webpack_module_cache__ = {};
|
/******/ var __webpack_module_cache__ = {};
|
||||||
/******/
|
/******/
|
||||||
/******/ // The require function
|
/******/ // The require function
|
||||||
/******/ function __webpack_require__(moduleId) {
|
/******/ function __nccwpck_require__(moduleId) {
|
||||||
/******/ // Check if module is in cache
|
/******/ // Check if module is in cache
|
||||||
/******/ if(__webpack_module_cache__[moduleId]) {
|
/******/ if(__webpack_module_cache__[moduleId]) {
|
||||||
/******/ return __webpack_module_cache__[moduleId].exports;
|
/******/ return __webpack_module_cache__[moduleId].exports;
|
||||||
@ -2183,7 +2286,7 @@ module.exports = require("zlib");
|
|||||||
/******/ // Execute the module function
|
/******/ // Execute the module function
|
||||||
/******/ var threw = true;
|
/******/ var threw = true;
|
||||||
/******/ try {
|
/******/ 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;
|
/******/ threw = false;
|
||||||
/******/ } finally {
|
/******/ } finally {
|
||||||
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
||||||
@ -2196,11 +2299,11 @@ module.exports = require("zlib");
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/******/ /* webpack/runtime/compat */
|
/******/ /* webpack/runtime/compat */
|
||||||
/******/
|
/******/
|
||||||
/******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/
|
/******/ __nccwpck_require__.ab = __dirname + "/";/************************************************************************/
|
||||||
/******/ // module exports must be returned from runtime so entry inlining is disabled
|
/******/ // module exports must be returned from runtime so entry inlining is disabled
|
||||||
/******/ // startup
|
/******/ // startup
|
||||||
/******/ // Load entry module and return exports
|
/******/ // Load entry module and return exports
|
||||||
/******/ return __webpack_require__(496);
|
/******/ return __nccwpck_require__(496);
|
||||||
/******/ })()
|
/******/ })()
|
||||||
;
|
;
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.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
34
dist/main.js
vendored
34
dist/main.js
vendored
@ -40,28 +40,48 @@ var core = require("@actions/core");
|
|||||||
var http_1 = require("./http");
|
var http_1 = require("./http");
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function () {
|
return __awaiter(this, void 0, void 0, function () {
|
||||||
var url, headers, body;
|
var url, headers, body, insecure;
|
||||||
return __generator(this, function (_a) {
|
return __generator(this, function (_a) {
|
||||||
url = core.getInput('url') ? core.getInput('url') : (process.env.WEBHOOK_URL ? process.env.WEBHOOK_URL : '');
|
url = core.getInput('url')
|
||||||
headers = core.getInput('headers') ? core.getInput('headers') : (process.env.headers ? process.env.headers : null);
|
? core.getInput('url')
|
||||||
body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
|
: 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) {
|
if (!url) {
|
||||||
core.setFailed('A url is required to run this action.');
|
core.setFailed('A url is required to run this action.');
|
||||||
throw new Error('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.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, insecure)
|
||||||
.then(function (res) {
|
.then(function (res) {
|
||||||
if (res.status >= 400) {
|
if (res.status >= 400) {
|
||||||
error(res.status);
|
error(res.status);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
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) {
|
||||||
error(err.status);
|
error(err.status);
|
||||||
|
return;
|
||||||
});
|
});
|
||||||
return [2];
|
return [2];
|
||||||
});
|
});
|
||||||
|
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,+BAA8B;AAE9B,SAAe,GAAG;;;;YACR,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CA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AA;gBACjB,OAAM;YACR,CAAC,CAAC,CAAA;;;;CACL;AAED,SAAS,KAAK,CAAC,UAAU;IAEvB,IAAI,CAAC,SAAS,CAAC,2BAAyB,UAAY,CAAC,CAAA;IAErD,MAAM,IAAI,KAAK,CAAC,sCAAoC,UAAY,CAAC,CAAA;AACnE,CAAC;AAED,GAAG,EAAE,CAAA"}
|
3911
dist/sourcemap-register.js
vendored
3911
dist/sourcemap-register.js
vendored
File diff suppressed because one or more lines are too long
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.
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "webhook-action",
|
"name": "webhook-action",
|
||||||
"version": "2.0.2",
|
"version": "2.1.0",
|
||||||
"description": "Github Webhook Action",
|
"description": "Github Webhook Action",
|
||||||
"main": "dist/main.js",
|
"main": "dist/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
38
src/http.ts
38
src/http.ts
@ -1,35 +1,47 @@
|
|||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch')
|
||||||
var https = require('https');
|
var https = require('https')
|
||||||
|
|
||||||
class Http {
|
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) => {
|
return new Promise((resolve, reject) => {
|
||||||
fetch(url, this.getOptions('post', headers, body, ignoreCertificate))
|
fetch(
|
||||||
.then((res: Response) => resolve(res));
|
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 = {
|
const options: any = {
|
||||||
headers: headers ? JSON.parse(headers) : {},
|
headers: headers ? JSON.parse(headers) : {},
|
||||||
method
|
method
|
||||||
};
|
}
|
||||||
|
|
||||||
if (body) {
|
if (body) {
|
||||||
// parse the body
|
// parse the body
|
||||||
options.body = body;
|
options.body = body
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignoreCertificate) {
|
if (ignoreCertificate) {
|
||||||
// ignore the certificate by not rejecting authorized servers
|
// 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
|
// 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()
|
||||||
|
65
src/main.ts
65
src/main.ts
@ -1,53 +1,70 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core'
|
||||||
import { http } from './http';
|
import {http} from './http'
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const url = core.getInput('url') ? core.getInput('url') : (process.env.WEBHOOK_URL ? process.env.WEBHOOK_URL : '');
|
const url = core.getInput('url')
|
||||||
const headers = core.getInput('headers') ? core.getInput('headers') : (process.env.headers ? process.env.headers : null);
|
? core.getInput('url')
|
||||||
const body = core.getInput('body') ? core.getInput('body') : (process.env.data ? process.env.data : null);
|
: process.env.WEBHOOK_URL
|
||||||
const insecure = core.getInput('insecure') ? core.getInput('insecure') == 'true' : (process.env.insecure ? process.env.insecure == 'true' : false);
|
? 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) {
|
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.')
|
||||||
// error
|
// error
|
||||||
throw new Error('A url is required to run this action.');
|
throw new Error('A url is required to run this action.')
|
||||||
}
|
}
|
||||||
|
|
||||||
// initial info
|
// initial info
|
||||||
core.info(`Sending webhook request to ${url}`);
|
core.info(`Sending webhook request to ${url}`)
|
||||||
|
|
||||||
// debug start
|
// debug start
|
||||||
core.debug((new Date()).toTimeString()); // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
|
core.debug(new Date().toTimeString()) // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
|
||||||
|
|
||||||
// make the request
|
// make the request
|
||||||
http.make(url, headers, body, insecure)
|
http
|
||||||
.then((res) => {
|
.make(url, headers, body, insecure)
|
||||||
|
.then(res => {
|
||||||
// if the status code is not 2xx
|
// if the status code is not 2xx
|
||||||
if (res.status >= 400) {
|
if (res.status >= 400) {
|
||||||
// throw an error
|
// throw an error
|
||||||
error(res.status);
|
error(res.status)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
core.info(`Received status code: ${res.status}`);
|
core.info(`Received status code: ${res.status}`)
|
||||||
// debug end
|
// debug end
|
||||||
core.info((new Date()).toTimeString());
|
core.info(new Date().toTimeString())
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
error(err.status)
|
||||||
|
return
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
|
||||||
error(err.status);
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function error(statusCode) {
|
function error(statusCode) {
|
||||||
// set the action to failed
|
// set the action to failed
|
||||||
core.setFailed(`Received status code: ${statusCode}`);
|
core.setFailed(`Received status code: ${statusCode}`)
|
||||||
// throw an error
|
// throw an error
|
||||||
throw new Error(`Request failed with status code: ${statusCode}`);
|
throw new Error(`Request failed with status code: ${statusCode}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
run();
|
run()
|
||||||
|
Loading…
Reference in New Issue
Block a user