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* () {
// Install Xcode for Mac OS
if (process.platform == 'darwin') {
let runner_ = new toolrunner.ToolRunner('xcode-select', ['--install']);
runner_.exec();
} else {
let runner0 = new toolrunner.ToolRunner('sudo',
['apt-get', 'update']);
runner0.exec();
let runner_ = new toolrunner.ToolRunner('sudo',
['apt-get', 'install', 'ruby-full', 'build-essential', 'postgresql', 'libpq-dev']);
yield runner_.exec();
}
// WORKAROUND, TODO: Parse version from Gemfile
let runner = null;
if (process.platform == 'darwin') {
runner = new toolrunner.ToolRunner('gem',
['install', 'bundler:1.17.2']);
} else {
runner = new toolrunner.ToolRunner('sudo',
['gem', 'install', 'bundler:1.17.2']);
}
return __awaiter(this, void 0, void 0, function* () {
// Create directory if not exists
yield io.mkdirP('config');
let runner0 = new toolrunner.ToolRunner('openssl', ['version']);
yield runner0.exec();
// TODO: also check that the key is valid after decryption
let runner = new toolrunner.ToolRunner('openssl',
['enc', '-d', '-aes-256-cbc', '-md', 'sha512', '-salt', '-in',
enc_rsa_key_pth, '-out', 'config/deploy_id_rsa', '-k', deploy_key, '-a']);
yield runner.exec();
});
}
if (process.platform == 'darwin') {
let runner_ = new toolrunner.ToolRunner('xcode-select', ['--install']);
runner_.exec();
} else {
let runner0 = new toolrunner.ToolRunner('sudo',
['apt-get', 'update']);
runner0.exec();
let runner_ = new toolrunner.ToolRunner('sudo',
['apt-get', 'install', 'ruby-full', 'build-essential', 'postgresql', 'libpq-dev']);
yield runner_.exec();
}
// WORKAROUND, TODO: Parse version from Gemfile
let runner = null;
if (process.platform == 'darwin') {
runner = new toolrunner.ToolRunner('gem',
['install', 'bundler:1.17.2']);
} else {
runner = new toolrunner.ToolRunner('sudo',
['gem', 'install', 'bundler:1.17.2']);
}
yield runner.exec();
//let runner0 = new toolrunner.ToolRunner('gem', ['install', 'capistrano', 'capistrano-rails']);
//yield runner0.exec();
//let runner1 = new toolrunner.ToolRunner('bundle', ['update', '--bundler']);
//yield runner1.exec();
let runner2 = null;
if (process.platform == 'darwin') {
runner2 = new toolrunner.ToolRunner('bundle', ['install', '--deployment']);
['install', 'bundler:1.17.2']);
} else {
runner = new toolrunner.ToolRunner('sudo',
['gem', 'install', 'bundler:1.17.2']);
}
yield runner.exec();
//let runner0 = new toolrunner.ToolRunner('gem', ['install', 'capistrano', 'capistrano-rails']);
//yield runner0.exec();
//let runner1 = new toolrunner.ToolRunner('bundle', ['update', '--bundler']);
//yield runner1.exec();
let runner2 = null;
if (process.platform == 'darwin') {
runner2 = new toolrunner.ToolRunner('bundle', ['install', '--deployment']);
} else {
runner2 = new toolrunner.ToolRunner('sudo', ['bundle', 'install', '--deployment']);
}
yield runner2.exec();
});
}
async function deleteSecret(namespace: string, secretName: string) {
let args = ['delete', 'secret', secretName];
if (namespace) {
args.push('-n', namespace);
}
const toolRunner = new ToolRunner(kubectlPath, args, { failOnStdErr: false, ignoreReturnCode: true, silent: true });
await toolRunner.exec();
core.debug(`Deleting ${secretName} if already exist.`);
}
async function setContext() {
let context = core.getInput('context');
if (context) {
const kubectlPath = await getKubectlPath();
let toolRunner = new ToolRunner(kubectlPath, ['config', 'use-context', context]);
await toolRunner.exec();
toolRunner = new ToolRunner(kubectlPath, ['config', 'current-context']);
await toolRunner.exec();
}
}
async function deploy(manifests: string[], namespace: string) {
if (manifests) {
for (var i = 0; i < manifests.length; i++) {
let manifest = manifests[i];
let toolRunner = new ToolRunner(kubectlPath, ['apply', '-f', manifest, '--namespace', namespace]);
await toolRunner.exec();
}
}
}
let args;
if (typeOfSecret === "docker-registry") {
args = getDockerSecretArguments(secretName);
}
else if (typeOfSecret === "generic") {
args = getGenericSecretArguments(secretName);
}
else {
throw new Error('Invalid secret-type input. It should be either docker-registry or generic');
}
if (namespace) {
args.push('-n', namespace);
}
const toolRunner = new ToolRunner(kubectlPath, args);
const code = await toolRunner.exec();
if (code != 0) {
throw new Error('Secret create failed.')
}
core.setOutput('secret-name', secretName);
}