Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return __awaiter(this, void 0, void 0, function* () {
let username = core.getInput('username', { required: true });
let password = core.getInput('password', { required: true });
let loginServer = core.getInput('login-server', { required: true });
let authenticationToken = new Buffer(`${username}:${password}`).toString('base64');
let config = {
"auths": {
[loginServer]: {
auth: authenticationToken
}
}
};
const runnerTempDirectory = process.env['RUNNER_TEMP']; // Using process.env until the core libs are updated
const dirPath = path.join(runnerTempDirectory, `docker_login_${Date.now()}`);
yield io.mkdirP(dirPath);
const dockerConfigPath = path.join(dirPath, `config.json`);
core.debug(`Writing docker config contents to ${dockerConfigPath}`);
fs.writeFileSync(dockerConfigPath, JSON.stringify(config));
command_1.issueCommand('set-env', { name: 'DOCKER_CONFIG' }, dirPath);
console.log('DOCKER_CONFIG environment variable is set');
});
}
function run() {
core.warning('This action is moved to azure/containers-actions repository, update your workflows to use those actions instead.');
let pathToDockerConfig = process.env['DOCKER_CONFIG'];
if (pathToDockerConfig && ioUtil.exists(pathToDockerConfig)) {
io.rmRF(pathToDockerConfig); // Deleting the docker config directory
core.debug(`${pathToDockerConfig} has been successfully deleted`);
};
issueCommand('set-env', { name: 'DOCKER_CONFIG' }, '');
console.log('DOCKER_CONFIG environment variable unset');
}
function run() {
core.warning('This action is moved to azure/containers-actions repository, update your workflows to use those actions instead.');
let pathToDockerConfig = process.env['DOCKER_CONFIG'];
if (pathToDockerConfig && ioUtil.exists(pathToDockerConfig)) {
io.rmRF(pathToDockerConfig); // Deleting the docker config directory
core.debug(`${pathToDockerConfig} has been successfully deleted`);
};
issueCommand('set-env', { name: 'DOCKER_CONFIG' }, '');
console.log('DOCKER_CONFIG environment variable unset');
}
function run() {
core.warning('This action is moved to azure/containers-actions repository, update your workflows to use those actions instead.');
let pathToDockerConfig = process.env['DOCKER_CONFIG'];
if (pathToDockerConfig && ioUtil.exists(pathToDockerConfig)) {
io.rmRF(pathToDockerConfig); // Deleting the docker config directory
core.debug(`${pathToDockerConfig} has been successfully deleted`);
}
;
command_1.issueCommand('set-env', { name: 'DOCKER_CONFIG' }, '');
console.log('DOCKER_CONFIG environment variable unset');
}
run();
async function _createExtractFolder(dest?: string): Promise {
if (!dest) {
// create a temp dir
dest = path.join(tempDirectory, uuidV4())
}
await io.mkdirP(dest)
return dest
}
return __awaiter(this, void 0, void 0, function* () {
if (!dest) {
// create a temp dir
dest = path.join(tempDirectory, uuidV4());
}
yield io.mkdirP(dest);
return dest;
});
}
return __awaiter(this, void 0, void 0, function* () {
if (!dest) {
// create a temp dir
dest = path.join(tempDirectory, uuidV4());
}
yield io.mkdirP(dest);
return dest;
});
}
process.env["USERPROFILE"] || "C:\\",
"Documents",
".Rprofile"
);
} else {
profilePath = path.join(process.env["HOME"] || "/Users", ".Rprofile");
}
core.debug("R profile is at " + profilePath);
await fs.writeFile(
profilePath,
`options(repos = '${process.env["CRAN"] ||
"https://cloud.r-project.org"}', crayon.enabled = TRUE, Ncpus = 2)\n`
);
// Make R_LIBS_USER
io.mkdirP(process.env["R_LIBS_USER"] || path.join(tempDirectory, "Library"));
}
return __awaiter(this, void 0, void 0, function* () {
// root the tool path if it is unrooted and contains relative pathing
if (!ioUtil.isRooted(this.toolPath) &&
(this.toolPath.includes('/') ||
(IS_WINDOWS && this.toolPath.includes('\\')))) {
// prefer options.cwd if it is specified, however options.cwd may also need to be rooted
this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath);
}
// if the tool is only a file name, then resolve it from the PATH
// otherwise verify it exists (add extension on Windows if necessary)
this.toolPath = yield io.which(this.toolPath, true);
return new Promise((resolve, reject) => {
this._debug(`exec tool: ${this.toolPath}`);
this._debug('arguments:');
for (const arg of this.args) {
this._debug(` ${arg}`);
}
const optionsNonNull = this._cloneExecOptions(this.options);
if (!optionsNonNull.silent && optionsNonNull.outStream) {
optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL);
}
const state = new ExecState(optionsNonNull, this.toolPath);
state.on('debug', (message) => {
this._debug(message);
});
const fileName = this._getSpawnFileName();
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
return __awaiter(this, void 0, void 0, function* () {
// build the powershell command
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
// run powershell
const powershellPath = yield io.which('powershell');
const args = [
'-NoLogo',
'-Sta',
'-NoProfile',
'-NonInteractive',
'-ExecutionPolicy',
'Unrestricted',
'-Command',
command
];
yield exec_1.exec(`"${powershellPath}"`, args);
});
}