cleanup.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. module.exports =
  2. /******/ (function(modules, runtime) { // webpackBootstrap
  3. /******/ "use strict";
  4. /******/ // The module cache
  5. /******/ var installedModules = {};
  6. /******/
  7. /******/ // The require function
  8. /******/ function __webpack_require__(moduleId) {
  9. /******/
  10. /******/ // Check if module is in cache
  11. /******/ if(installedModules[moduleId]) {
  12. /******/ return installedModules[moduleId].exports;
  13. /******/ }
  14. /******/ // Create a new module (and put it into the cache)
  15. /******/ var module = installedModules[moduleId] = {
  16. /******/ i: moduleId,
  17. /******/ l: false,
  18. /******/ exports: {}
  19. /******/ };
  20. /******/
  21. /******/ // Execute the module function
  22. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  23. /******/
  24. /******/ // Flag the module as loaded
  25. /******/ module.l = true;
  26. /******/
  27. /******/ // Return the exports of the module
  28. /******/ return module.exports;
  29. /******/ }
  30. /******/
  31. /******/
  32. /******/ __webpack_require__.ab = __dirname + "/";
  33. /******/
  34. /******/ // the startup function
  35. /******/ function startup() {
  36. /******/ // Load entry module and return exports
  37. /******/ return __webpack_require__(175);
  38. /******/ };
  39. /******/
  40. /******/ // run startup
  41. /******/ return startup();
  42. /******/ })
  43. /************************************************************************/
  44. /******/ ({
  45. /***/ 82:
  46. /***/ (function(__unusedmodule, exports) {
  47. "use strict";
  48. // We use any as a valid input type
  49. /* eslint-disable @typescript-eslint/no-explicit-any */
  50. Object.defineProperty(exports, "__esModule", { value: true });
  51. /**
  52. * Sanitizes an input into a string so it can be passed into issueCommand safely
  53. * @param input input to sanitize into a string
  54. */
  55. function toCommandValue(input) {
  56. if (input === null || input === undefined) {
  57. return '';
  58. }
  59. else if (typeof input === 'string' || input instanceof String) {
  60. return input;
  61. }
  62. return JSON.stringify(input);
  63. }
  64. exports.toCommandValue = toCommandValue;
  65. //# sourceMappingURL=utils.js.map
  66. /***/ }),
  67. /***/ 87:
  68. /***/ (function(module) {
  69. module.exports = require("os");
  70. /***/ }),
  71. /***/ 102:
  72. /***/ (function(__unusedmodule, exports, __webpack_require__) {
  73. "use strict";
  74. // For internal use, subject to change.
  75. var __importStar = (this && this.__importStar) || function (mod) {
  76. if (mod && mod.__esModule) return mod;
  77. var result = {};
  78. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  79. result["default"] = mod;
  80. return result;
  81. };
  82. Object.defineProperty(exports, "__esModule", { value: true });
  83. // We use any as a valid input type
  84. /* eslint-disable @typescript-eslint/no-explicit-any */
  85. const fs = __importStar(__webpack_require__(747));
  86. const os = __importStar(__webpack_require__(87));
  87. const utils_1 = __webpack_require__(82);
  88. function issueCommand(command, message) {
  89. const filePath = process.env[`GITHUB_${command}`];
  90. if (!filePath) {
  91. throw new Error(`Unable to find environment variable for file command ${command}`);
  92. }
  93. if (!fs.existsSync(filePath)) {
  94. throw new Error(`Missing file at path: ${filePath}`);
  95. }
  96. fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
  97. encoding: 'utf8'
  98. });
  99. }
  100. exports.issueCommand = issueCommand;
  101. //# sourceMappingURL=file-command.js.map
  102. /***/ }),
  103. /***/ 129:
  104. /***/ (function(module) {
  105. module.exports = require("child_process");
  106. /***/ }),
  107. /***/ 175:
  108. /***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
  109. const core = __webpack_require__(470);
  110. const { execFileSync } = __webpack_require__(129);
  111. const { sshAgent } = __webpack_require__(972);
  112. try {
  113. // Kill the started SSH agent
  114. console.log('Stopping SSH agent');
  115. execFileSync(sshAgent, ['-k'], { stdio: 'inherit' });
  116. } catch (error) {
  117. console.log(error.message);
  118. console.log('Error stopping the SSH agent, proceeding anyway');
  119. }
  120. /***/ }),
  121. /***/ 431:
  122. /***/ (function(__unusedmodule, exports, __webpack_require__) {
  123. "use strict";
  124. var __importStar = (this && this.__importStar) || function (mod) {
  125. if (mod && mod.__esModule) return mod;
  126. var result = {};
  127. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  128. result["default"] = mod;
  129. return result;
  130. };
  131. Object.defineProperty(exports, "__esModule", { value: true });
  132. const os = __importStar(__webpack_require__(87));
  133. const utils_1 = __webpack_require__(82);
  134. /**
  135. * Commands
  136. *
  137. * Command Format:
  138. * ::name key=value,key=value::message
  139. *
  140. * Examples:
  141. * ::warning::This is the message
  142. * ::set-env name=MY_VAR::some value
  143. */
  144. function issueCommand(command, properties, message) {
  145. const cmd = new Command(command, properties, message);
  146. process.stdout.write(cmd.toString() + os.EOL);
  147. }
  148. exports.issueCommand = issueCommand;
  149. function issue(name, message = '') {
  150. issueCommand(name, {}, message);
  151. }
  152. exports.issue = issue;
  153. const CMD_STRING = '::';
  154. class Command {
  155. constructor(command, properties, message) {
  156. if (!command) {
  157. command = 'missing.command';
  158. }
  159. this.command = command;
  160. this.properties = properties;
  161. this.message = message;
  162. }
  163. toString() {
  164. let cmdStr = CMD_STRING + this.command;
  165. if (this.properties && Object.keys(this.properties).length > 0) {
  166. cmdStr += ' ';
  167. let first = true;
  168. for (const key in this.properties) {
  169. if (this.properties.hasOwnProperty(key)) {
  170. const val = this.properties[key];
  171. if (val) {
  172. if (first) {
  173. first = false;
  174. }
  175. else {
  176. cmdStr += ',';
  177. }
  178. cmdStr += `${key}=${escapeProperty(val)}`;
  179. }
  180. }
  181. }
  182. }
  183. cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
  184. return cmdStr;
  185. }
  186. }
  187. function escapeData(s) {
  188. return utils_1.toCommandValue(s)
  189. .replace(/%/g, '%25')
  190. .replace(/\r/g, '%0D')
  191. .replace(/\n/g, '%0A');
  192. }
  193. function escapeProperty(s) {
  194. return utils_1.toCommandValue(s)
  195. .replace(/%/g, '%25')
  196. .replace(/\r/g, '%0D')
  197. .replace(/\n/g, '%0A')
  198. .replace(/:/g, '%3A')
  199. .replace(/,/g, '%2C');
  200. }
  201. //# sourceMappingURL=command.js.map
  202. /***/ }),
  203. /***/ 470:
  204. /***/ (function(__unusedmodule, exports, __webpack_require__) {
  205. "use strict";
  206. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  207. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  208. return new (P || (P = Promise))(function (resolve, reject) {
  209. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  210. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  211. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  212. step((generator = generator.apply(thisArg, _arguments || [])).next());
  213. });
  214. };
  215. var __importStar = (this && this.__importStar) || function (mod) {
  216. if (mod && mod.__esModule) return mod;
  217. var result = {};
  218. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  219. result["default"] = mod;
  220. return result;
  221. };
  222. Object.defineProperty(exports, "__esModule", { value: true });
  223. const command_1 = __webpack_require__(431);
  224. const file_command_1 = __webpack_require__(102);
  225. const utils_1 = __webpack_require__(82);
  226. const os = __importStar(__webpack_require__(87));
  227. const path = __importStar(__webpack_require__(622));
  228. /**
  229. * The code to exit an action
  230. */
  231. var ExitCode;
  232. (function (ExitCode) {
  233. /**
  234. * A code indicating that the action was successful
  235. */
  236. ExitCode[ExitCode["Success"] = 0] = "Success";
  237. /**
  238. * A code indicating that the action was a failure
  239. */
  240. ExitCode[ExitCode["Failure"] = 1] = "Failure";
  241. })(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
  242. //-----------------------------------------------------------------------
  243. // Variables
  244. //-----------------------------------------------------------------------
  245. /**
  246. * Sets env variable for this action and future actions in the job
  247. * @param name the name of the variable to set
  248. * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
  249. */
  250. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  251. function exportVariable(name, val) {
  252. const convertedVal = utils_1.toCommandValue(val);
  253. process.env[name] = convertedVal;
  254. const filePath = process.env['GITHUB_ENV'] || '';
  255. if (filePath) {
  256. const delimiter = '_GitHubActionsFileCommandDelimeter_';
  257. const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
  258. file_command_1.issueCommand('ENV', commandValue);
  259. }
  260. else {
  261. command_1.issueCommand('set-env', { name }, convertedVal);
  262. }
  263. }
  264. exports.exportVariable = exportVariable;
  265. /**
  266. * Registers a secret which will get masked from logs
  267. * @param secret value of the secret
  268. */
  269. function setSecret(secret) {
  270. command_1.issueCommand('add-mask', {}, secret);
  271. }
  272. exports.setSecret = setSecret;
  273. /**
  274. * Prepends inputPath to the PATH (for this action and future actions)
  275. * @param inputPath
  276. */
  277. function addPath(inputPath) {
  278. const filePath = process.env['GITHUB_PATH'] || '';
  279. if (filePath) {
  280. file_command_1.issueCommand('PATH', inputPath);
  281. }
  282. else {
  283. command_1.issueCommand('add-path', {}, inputPath);
  284. }
  285. process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
  286. }
  287. exports.addPath = addPath;
  288. /**
  289. * Gets the value of an input. The value is also trimmed.
  290. *
  291. * @param name name of the input to get
  292. * @param options optional. See InputOptions.
  293. * @returns string
  294. */
  295. function getInput(name, options) {
  296. const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
  297. if (options && options.required && !val) {
  298. throw new Error(`Input required and not supplied: ${name}`);
  299. }
  300. return val.trim();
  301. }
  302. exports.getInput = getInput;
  303. /**
  304. * Sets the value of an output.
  305. *
  306. * @param name name of the output to set
  307. * @param value value to store. Non-string values will be converted to a string via JSON.stringify
  308. */
  309. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  310. function setOutput(name, value) {
  311. command_1.issueCommand('set-output', { name }, value);
  312. }
  313. exports.setOutput = setOutput;
  314. /**
  315. * Enables or disables the echoing of commands into stdout for the rest of the step.
  316. * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
  317. *
  318. */
  319. function setCommandEcho(enabled) {
  320. command_1.issue('echo', enabled ? 'on' : 'off');
  321. }
  322. exports.setCommandEcho = setCommandEcho;
  323. //-----------------------------------------------------------------------
  324. // Results
  325. //-----------------------------------------------------------------------
  326. /**
  327. * Sets the action status to failed.
  328. * When the action exits it will be with an exit code of 1
  329. * @param message add error issue message
  330. */
  331. function setFailed(message) {
  332. process.exitCode = ExitCode.Failure;
  333. error(message);
  334. }
  335. exports.setFailed = setFailed;
  336. //-----------------------------------------------------------------------
  337. // Logging Commands
  338. //-----------------------------------------------------------------------
  339. /**
  340. * Gets whether Actions Step Debug is on or not
  341. */
  342. function isDebug() {
  343. return process.env['RUNNER_DEBUG'] === '1';
  344. }
  345. exports.isDebug = isDebug;
  346. /**
  347. * Writes debug message to user log
  348. * @param message debug message
  349. */
  350. function debug(message) {
  351. command_1.issueCommand('debug', {}, message);
  352. }
  353. exports.debug = debug;
  354. /**
  355. * Adds an error issue
  356. * @param message error issue message. Errors will be converted to string via toString()
  357. */
  358. function error(message) {
  359. command_1.issue('error', message instanceof Error ? message.toString() : message);
  360. }
  361. exports.error = error;
  362. /**
  363. * Adds an warning issue
  364. * @param message warning issue message. Errors will be converted to string via toString()
  365. */
  366. function warning(message) {
  367. command_1.issue('warning', message instanceof Error ? message.toString() : message);
  368. }
  369. exports.warning = warning;
  370. /**
  371. * Writes info to log with console.log.
  372. * @param message info message
  373. */
  374. function info(message) {
  375. process.stdout.write(message + os.EOL);
  376. }
  377. exports.info = info;
  378. /**
  379. * Begin an output group.
  380. *
  381. * Output until the next `groupEnd` will be foldable in this group
  382. *
  383. * @param name The name of the output group
  384. */
  385. function startGroup(name) {
  386. command_1.issue('group', name);
  387. }
  388. exports.startGroup = startGroup;
  389. /**
  390. * End an output group.
  391. */
  392. function endGroup() {
  393. command_1.issue('endgroup');
  394. }
  395. exports.endGroup = endGroup;
  396. /**
  397. * Wrap an asynchronous function call in a group.
  398. *
  399. * Returns the same type as the function itself.
  400. *
  401. * @param name The name of the group
  402. * @param fn The function to wrap in the group
  403. */
  404. function group(name, fn) {
  405. return __awaiter(this, void 0, void 0, function* () {
  406. startGroup(name);
  407. let result;
  408. try {
  409. result = yield fn();
  410. }
  411. finally {
  412. endGroup();
  413. }
  414. return result;
  415. });
  416. }
  417. exports.group = group;
  418. //-----------------------------------------------------------------------
  419. // Wrapper action state
  420. //-----------------------------------------------------------------------
  421. /**
  422. * Saves state for current action, the state can only be retrieved by this action's post job execution.
  423. *
  424. * @param name name of the state to store
  425. * @param value value to store. Non-string values will be converted to a string via JSON.stringify
  426. */
  427. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  428. function saveState(name, value) {
  429. command_1.issueCommand('save-state', { name }, value);
  430. }
  431. exports.saveState = saveState;
  432. /**
  433. * Gets the value of an state set by this action's main execution.
  434. *
  435. * @param name name of the state to get
  436. * @returns string
  437. */
  438. function getState(name) {
  439. return process.env[`STATE_${name}`] || '';
  440. }
  441. exports.getState = getState;
  442. //# sourceMappingURL=core.js.map
  443. /***/ }),
  444. /***/ 622:
  445. /***/ (function(module) {
  446. module.exports = require("path");
  447. /***/ }),
  448. /***/ 747:
  449. /***/ (function(module) {
  450. module.exports = require("fs");
  451. /***/ }),
  452. /***/ 972:
  453. /***/ (function(module, __unusedexports, __webpack_require__) {
  454. const os = __webpack_require__(87);
  455. module.exports = (process.env['OS'] != 'Windows_NT') ? {
  456. // Use getent() system call, since this is what ssh does; makes a difference in Docker-based
  457. // Action runs, where $HOME is different from the pwent
  458. home: os.userInfo().homedir,
  459. sshAgent: 'ssh-agent',
  460. sshAdd: 'ssh-add'
  461. } : {
  462. home: os.homedir(),
  463. sshAgent: 'c://progra~1//git//usr//bin//ssh-agent.exe',
  464. sshAdd: 'c://progra~1//git//usr//bin//ssh-add.exe'
  465. };
  466. /***/ })
  467. /******/ });