env/dist/index.js

647 lines
20 KiB
JavaScript
Raw Normal View History

2020-07-13 06:12:00 -04:00
module.exports =
2020-11-28 01:55:14 -05:00
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
2020-07-13 06:12:00 -04:00
2020-11-28 01:55:14 -05:00
/***/ 932:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2020-07-13 06:12:00 -04:00
// Franz Diebold
2020-11-28 01:55:14 -05:00
const core = __webpack_require__(186);
2020-07-13 06:12:00 -04:00
2020-07-16 05:24:46 -04:00
/**
* Slugify a given string.
* @param {string} inputString
* @return {string} The slugified string.
*/
function slugify(inputString) {
return inputString
.toLowerCase()
.replace(/[^a-z0-9 -]/g, ' ') // remove invalid chars
.replace(/^\s+|\s+$/g, '') // trim
.replace(/\s+/g, '-') // collapse whitespace and replace by -
.replace(/-+/g, '-'); // collapse dashes
}
2020-07-14 06:06:58 -04:00
/**
* Get the repository owner from the repository string.
* @param {string} repository
* @return {string} The owner of the repository.
*/
function getRepositoryOwner(repository) {
2020-07-14 06:06:58 -04:00
return repository ? repository.split('/')[0] : null;
}
2020-07-14 06:06:58 -04:00
/**
* Get the repository name from the repository string.
* @param {string} repository
* @return {string} The name of the repository.
*/
function getRepositoryName(repository) {
2020-07-14 06:06:58 -04:00
return repository ? repository.split('/')[1] : null;
}
2020-07-14 06:06:58 -04:00
/**
* Get the ref name from the ref string.
* @param {string} ref
* @return {string} The ref name.
*/
function getRefName(ref) {
2020-07-14 06:06:58 -04:00
return ref ? ref.split('/').slice(2).join('/') : null;
}
/**
* Get the short SHA from the full SHA.
* @param {string} fullSha
* @return {string} The short SHA.
*/
function getShaShort(fullSha) {
return fullSha ? fullSha.substring(0, 8) : null;
2020-07-13 06:12:00 -04:00
}
// https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables
try {
2020-07-14 06:06:58 -04:00
// i.e. FranzDiebold/github-env-vars-action
repository = process.env.GITHUB_REPOSITORY;
2020-07-13 06:12:00 -04:00
2020-07-16 05:24:46 -04:00
if (repository) {
core.exportVariable('GITHUB_REPOSITORY_SLUG', slugify(repository));
core.info(`Set GITHUB_REPOSITORY_SLUG=` +
`${process.env.GITHUB_REPOSITORY_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REPOSITORY" not set. ' +
'Cannot set "GITHUB_REPOSITORY_SLUG".');
}
2020-07-14 06:06:58 -04:00
repositoryOwner = getRepositoryOwner(repository);
if (repositoryOwner) {
core.exportVariable('GITHUB_REPOSITORY_OWNER', repositoryOwner);
core.info(`Set GITHUB_REPOSITORY_OWNER=` +
`${process.env.GITHUB_REPOSITORY_OWNER}`);
2020-07-16 05:24:46 -04:00
core.exportVariable('GITHUB_REPOSITORY_OWNER_SLUG',
slugify(repositoryOwner));
core.info(`Set GITHUB_REPOSITORY_OWNER_SLUG=` +
`${process.env.GITHUB_REPOSITORY_OWNER_SLUG}`);
2020-07-14 06:06:58 -04:00
} else {
core.warning('Environment variable "GITHUB_REPOSITORY" not set. ' +
2020-07-16 05:24:46 -04:00
'Cannot set "GITHUB_REPOSITORY_OWNER" and ' +
'"GITHUB_REPOSITORY_OWNER_SLUG".');
2020-07-14 06:06:58 -04:00
}
2020-07-13 06:12:00 -04:00
2020-07-14 06:06:58 -04:00
repositoryName = getRepositoryName(repository);
if (repositoryName) {
core.exportVariable('GITHUB_REPOSITORY_NAME', repositoryName);
core.info(`Set GITHUB_REPOSITORY_NAME=` +
`${process.env.GITHUB_REPOSITORY_NAME}`);
2020-07-16 05:24:46 -04:00
core.exportVariable('GITHUB_REPOSITORY_NAME_SLUG',
slugify(repositoryName));
core.info(`Set GITHUB_REPOSITORY_NAME_SLUG=` +
`${process.env.GITHUB_REPOSITORY_NAME_SLUG}`);
2020-07-14 06:06:58 -04:00
} else {
core.warning('Environment variable "GITHUB_REPOSITORY" not set. ' +
2020-07-16 05:24:46 -04:00
'Cannot set "GITHUB_REPOSITORY_NAME" and ' +
'"GITHUB_REPOSITORY_NAME_SLUG".');
2020-07-14 06:06:58 -04:00
}
2020-07-13 06:12:00 -04:00
2020-07-14 06:06:58 -04:00
// i.e. refs/heads/feat/feature-branch-1
2020-07-16 05:24:46 -04:00
ref = process.env.GITHUB_REF;
if (ref) {
2020-07-16 05:38:50 -04:00
core.exportVariable('GITHUB_REF_SLUG', slugify(ref));
2020-07-16 05:24:46 -04:00
core.info(`Set GITHUB_REF_SLUG=${process.env.GITHUB_REF_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_REF" not set. ' +
'Cannot set "GITHUB_REF_SLUG".');
}
refName = getRefName(ref);
2020-07-14 06:06:58 -04:00
if (refName) {
core.exportVariable('GITHUB_REF_NAME', refName);
core.info(`Set GITHUB_REF_NAME=${process.env.GITHUB_REF_NAME}`);
2020-07-16 05:24:46 -04:00
2020-07-16 05:38:50 -04:00
core.exportVariable('GITHUB_REF_NAME_SLUG', slugify(refName));
2020-07-16 05:24:46 -04:00
core.info(`Set GITHUB_REF_NAME_SLUG=${process.env.GITHUB_REF_NAME_SLUG}`);
2020-07-14 06:06:58 -04:00
} else {
core.warning('Environment variable "GITHUB_REF" not set. ' +
2020-07-16 05:24:46 -04:00
'Cannot set "GITHUB_REF_NAME" and ' +
'"GITHUB_REF_NAME_SLUG".');
2020-07-14 06:06:58 -04:00
}
2020-11-27 15:53:34 -05:00
headRef = process.env.GITHUB_HEAD_REF;
branchName = headRef || refName;
if (branchName) {
core.exportVariable('GITHUB_BRANCH_NAME', branchName);
core.info(`Set GITHUB_BRANCH_NAME=${process.env.GITHUB_BRANCH_NAME}`);
core.exportVariable('GITHUB_BRANCH_NAME_SLUG', slugify(branchName));
core.info('Set GITHUB_BRANCH_NAME_SLUG=' +
`${process.env.GITHUB_BRANCH_NAME_SLUG}`);
} else {
core.warning('Environment variables "GITHUB_REF" and ' +
'"GITHUB_HEAD_REF" not set. ' +
'Cannot set "GITHUB_BRANCH_NAME" and ' +
'"GITHUB_BRANCH_NAME_SLUG".');
}
if (headRef) {
core.exportVariable('GITHUB_HEAD_REF_SLUG', slugify(headRef));
core.info(`Set GITHUB_HEAD_REF_SLUG=${process.env.GITHUB_HEAD_REF_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_HEAD_REF" not set. ' +
'Cannot set "GITHUB_HEAD_REF_SLUG".');
}
baseRef = process.env.GITHUB_BASE_REF;
if (baseRef) {
core.exportVariable('GITHUB_BASE_REF_SLUG', slugify(baseRef));
core.info(`Set GITHUB_BASE_REF_SLUG=${process.env.GITHUB_BASE_REF_SLUG}`);
} else {
core.warning('Environment variable "GITHUB_BASE_REF" not set. ' +
'Cannot set "GITHUB_BASE_REF_SLUG".');
}
2020-07-14 06:06:58 -04:00
// i.e. ffac537e6cbbf934b08745a378932722df287a53
shaShort = getShaShort(process.env.GITHUB_SHA);
if (shaShort) {
core.exportVariable('GITHUB_SHA_SHORT', shaShort);
core.info(`Set GITHUB_SHA_SHORT=${process.env.GITHUB_SHA_SHORT}`);
} else {
core.warning('Environment variable "GITHUB_SHA" not set. ' +
'Cannot set "GITHUB_SHA_SHORT".');
}
2020-07-13 06:12:00 -04:00
} catch (error) {
2020-07-14 06:06:58 -04:00
core.setFailed(error.message);
2020-07-13 06:12:00 -04:00
}
2020-07-14 06:06:58 -04:00
module.exports = {
2020-07-16 05:24:46 -04:00
slugify,
2020-07-14 06:06:58 -04:00
getRepositoryOwner,
getRepositoryName,
getRefName,
getShaShort,
};
2020-07-13 06:12:00 -04:00
2020-10-05 02:54:23 -04:00
/***/ }),
2020-11-28 01:55:14 -05:00
/***/ 351:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
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 }));
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(278);
/**
* Commands
*
* Command Format:
* ::name key=value,key=value::message
*
* Examples:
* ::warning::This is the message
* ::set-env name=MY_VAR::some value
*/
function issueCommand(command, properties, message) {
const cmd = new Command(command, properties, message);
process.stdout.write(cmd.toString() + os.EOL);
}
exports.issueCommand = issueCommand;
function issue(name, message = '') {
issueCommand(name, {}, message);
}
exports.issue = issue;
const CMD_STRING = '::';
class Command {
constructor(command, properties, message) {
if (!command) {
command = 'missing.command';
}
this.command = command;
this.properties = properties;
this.message = message;
}
toString() {
let cmdStr = CMD_STRING + this.command;
if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' ';
let first = true;
for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) {
const val = this.properties[key];
if (val) {
if (first) {
first = false;
}
else {
cmdStr += ',';
}
cmdStr += `${key}=${escapeProperty(val)}`;
}
}
}
}
cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
return cmdStr;
}
}
function escapeData(s) {
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A');
}
function escapeProperty(s) {
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A')
.replace(/:/g, '%3A')
.replace(/,/g, '%2C');
}
//# sourceMappingURL=command.js.map
2020-10-05 02:54:23 -04:00
2020-11-28 01:55:14 -05:00
/***/ }),
/***/ 186:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2020-10-05 02:54:23 -04:00
2020-11-28 01:55:14 -05:00
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
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 }));
const command_1 = __webpack_require__(351);
const file_command_1 = __webpack_require__(717);
const utils_1 = __webpack_require__(278);
const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622));
/**
* The code to exit an action
*/
var ExitCode;
(function (ExitCode) {
/**
* A code indicating that the action was successful
*/
ExitCode[ExitCode["Success"] = 0] = "Success";
/**
* A code indicating that the action was a failure
*/
ExitCode[ExitCode["Failure"] = 1] = "Failure";
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
//-----------------------------------------------------------------------
// Variables
//-----------------------------------------------------------------------
/**
* Sets env variable for this action and future actions in the job
* @param name the name of the variable to set
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) {
const convertedVal = utils_1.toCommandValue(val);
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);
}
}
exports.exportVariable = exportVariable;
/**
* Registers a secret which will get masked from logs
* @param secret value of the secret
*/
function setSecret(secret) {
command_1.issueCommand('add-mask', {}, secret);
}
exports.setSecret = setSecret;
/**
* Prepends inputPath to the PATH (for this action and future actions)
* @param 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);
}
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
}
exports.addPath = addPath;
/**
* Gets the value of an input. The value is also trimmed.
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns string
*/
function getInput(name, options) {
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
return val.trim();
}
exports.getInput = getInput;
/**
* Sets the value of an output.
*
* @param name name of the output to set
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setOutput(name, value) {
command_1.issueCommand('set-output', { name }, value);
}
exports.setOutput = setOutput;
/**
* Enables or disables the echoing of commands into stdout for the rest of the step.
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
*
*/
function setCommandEcho(enabled) {
command_1.issue('echo', enabled ? 'on' : 'off');
}
exports.setCommandEcho = setCommandEcho;
//-----------------------------------------------------------------------
// Results
//-----------------------------------------------------------------------
/**
* Sets the action status to failed.
* When the action exits it will be with an exit code of 1
* @param message add error issue message
*/
function setFailed(message) {
process.exitCode = ExitCode.Failure;
error(message);
}
exports.setFailed = setFailed;
//-----------------------------------------------------------------------
// Logging Commands
//-----------------------------------------------------------------------
/**
* Gets whether Actions Step Debug is on or not
*/
function isDebug() {
return process.env['RUNNER_DEBUG'] === '1';
}
exports.isDebug = isDebug;
/**
* Writes debug message to user log
* @param message debug message
*/
function debug(message) {
command_1.issueCommand('debug', {}, message);
}
exports.debug = debug;
/**
* Adds an error issue
* @param message error issue message. Errors will be converted to string via toString()
*/
function error(message) {
command_1.issue('error', message instanceof Error ? message.toString() : message);
}
exports.error = error;
/**
* Adds an warning issue
* @param message warning issue message. Errors will be converted to string via toString()
*/
function warning(message) {
command_1.issue('warning', message instanceof Error ? message.toString() : message);
}
exports.warning = warning;
/**
* Writes info to log with console.log.
* @param message info message
*/
function info(message) {
process.stdout.write(message + os.EOL);
}
exports.info = info;
/**
* Begin an output group.
*
* Output until the next `groupEnd` will be foldable in this group
*
* @param name The name of the output group
*/
function startGroup(name) {
command_1.issue('group', name);
}
exports.startGroup = startGroup;
/**
* End an output group.
*/
function endGroup() {
command_1.issue('endgroup');
}
exports.endGroup = endGroup;
/**
* Wrap an asynchronous function call in a group.
*
* Returns the same type as the function itself.
*
* @param name The name of the group
* @param fn The function to wrap in the group
*/
function group(name, fn) {
return __awaiter(this, void 0, void 0, function* () {
startGroup(name);
let result;
try {
result = yield fn();
}
finally {
endGroup();
}
return result;
});
}
exports.group = group;
//-----------------------------------------------------------------------
// Wrapper action state
//-----------------------------------------------------------------------
/**
* Saves state for current action, the state can only be retrieved by this action's post job execution.
*
* @param name name of the state to store
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function saveState(name, value) {
command_1.issueCommand('save-state', { name }, value);
}
exports.saveState = saveState;
/**
* Gets the value of an state set by this action's main execution.
*
* @param name name of the state to get
* @returns string
*/
function getState(name) {
return process.env[`STATE_${name}`] || '';
}
exports.getState = getState;
//# sourceMappingURL=core.js.map
/***/ }),
/***/ 717:
/***/ (function(__unused_webpack_module, exports, __webpack_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(__webpack_require__(747));
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_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
/***/ }),
/***/ 747:
/***/ ((module) => {
"use strict";
module.exports = require("fs");;
/***/ }),
/***/ 87:
/***/ ((module) => {
"use strict";
module.exports = require("os");;
/***/ }),
/***/ 622:
/***/ ((module) => {
"use strict";
module.exports = require("path");;
2020-07-13 06:12:00 -04:00
/***/ })
2020-11-28 01:55:14 -05:00
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ var threw = true;
/******/ try {
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete __webpack_module_cache__[moduleId];
/******/ }
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat */
/******/
/******/ __webpack_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__(932);
/******/ })()
;