Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function run() {
const branch = core.getInput('branch', { required: false }) || 'master';
const result = await semanticRelease({ branch });
if (!result) {
core.debug('No release published');
// set outputs
core.exportVariable('NEW_RELEASE_PUBLISHED', 'false');
core.setOutput('new-release-published', 'false');
return;
}
const { lastRelease, nextRelease, commits } = result;
core.debug(
`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`,
);
if (lastRelease.version) {
core.debug(`The last release was "${lastRelease.version}".`);
}
// outputs
const { version } = nextRelease;
const major = version.split('.')[0];
const minor = version.split('.')[1];
const patch = version.split('.')[2];
// set outputs
core.exportVariable('NEW_RELEASE_PUBLISHED', 'true');
core.exportVariable('RELEASE_VERSION', version);
export async function signApkFile(
apkFile: string,
signingKeyFile: string,
alias: string,
keyStorePassword: string,
keyPassword: string
): Promise {
core.debug("Zipaligning APK file");
// Find zipalign executable
const buildToolsVersion = process.env.BUILD_TOOLS_VERSION || '29.0.2';
const androidHome = process.env.ANDROID_HOME;
const buildTools = path.join(androidHome!, `build-tools/${buildToolsVersion}`);
if (!fs.existsSync(buildTools)) {
core.error(`Couldnt find the Android build tools @ ${buildTools}`)
}
const zipAlign = path.join(buildTools, 'zipalign');
core.debug(`Found 'zipalign' @ ${zipAlign}`);
// Align the apk file
const alignedApkFile = apkFile.replace('.apk', '-aligned.apk');
await exec.exec(`"${zipAlign}"`, [
'-v', '-p', '4',
async function acquireRWindows(version: string): Promise {
let fileName: string = getFileNameWindows(version);
let downloadUrl: string = getDownloadUrlWindows(version);
let downloadPath: string | null = null;
try {
downloadPath = await tc.downloadTool(downloadUrl);
await io.mv(downloadPath, path.join(tempDirectory, fileName));
} catch (error) {
core.debug(error);
throw `Failed to download version ${version}: ${error}`;
}
//
// Install
//
let extPath: string = tempDirectory;
if (!extPath) {
throw new Error("Temp directory not set");
}
try {
await exec.exec(path.join(tempDirectory, fileName), [
"/VERYSILENT",
"/SUPPRESSMSGBOXES",
yaml.safeLoadAll(fileContents, function (inputObject) {
const name = inputObject.metadata.name;
const kind = inputObject.kind;
if (helper.isDeploymentEntity(kind)) {
// Get stable object
core.debug('Querying stable object');
const stableObject = canaryDeploymentHelper.fetchResource(kubectl, kind, name);
if (!stableObject) {
core.debug('Stable object not found. Creating only canary object');
// If stable object not found, create canary deployment.
const newCanaryObject = canaryDeploymentHelper.getNewCanaryResource(inputObject, canaryReplicaCount);
core.debug('New canary object is: ' + JSON.stringify(newCanaryObject));
newObjectsList.push(newCanaryObject);
} else {
if (!canaryDeploymentHelper.isResourceMarkedAsStable(stableObject)) {
throw (`StableSpecSelectorNotExist : ${name}`);
}
core.debug('Stable object found. Creating canary and baseline objects');
// If canary object not found, create canary and baseline object.
const newCanaryObject = canaryDeploymentHelper.getNewCanaryResource(inputObject, canaryReplicaCount);
const newBaselineObject = canaryDeploymentHelper.getNewBaselineResource(stableObject, canaryReplicaCount);
core.debug('New canary object is: ' + JSON.stringify(newCanaryObject));
core.debug('New baseline object is: ' + JSON.stringify(newBaselineObject));
newObjectsList.push(newCanaryObject);
// Wait for deployment to complete
if (waitForService && waitForService.toLowerCase() === 'true') {
// Determine wait time
const deployReadyWaitMin = deploymentGroupDetails.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes;
const terminationWaitMin = deploymentGroupDetails.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes;
let totalWaitMin = deployReadyWaitMin + terminationWaitMin + CODE_DEPLOY_WAIT_BUFFER_MINUTES;
if (totalWaitMin > CODE_DEPLOY_MAX_WAIT_MINUTES) {
totalWaitMin = CODE_DEPLOY_MAX_WAIT_MINUTES;
}
if (totalWaitMin < CODE_DEPLOY_MIN_WAIT_MINUTES) {
totalWaitMin = CODE_DEPLOY_MIN_WAIT_MINUTES;
}
const maxAttempts = (totalWaitMin * 60) / CODE_DEPLOY_WAIT_DEFAULT_DELAY_SEC;
core.debug(`Waiting for the deployment to complete. Will wait for ${totalWaitMin} minutes`);
await codedeploy.waitFor('deploymentSuccessful', {
deploymentId: createDeployResponse.deploymentId,
$waiter: {
delay: CODE_DEPLOY_WAIT_DEFAULT_DELAY_SEC,
maxAttempts: maxAttempts
}
}).promise();
} else {
core.debug('Not waiting for the deployment to complete');
}
}
let cachePath = utils.resolvePath(
core.getInput(Inputs.Path, { required: true })
);
core.debug(`Cache Path: ${cachePath}`);
const primaryKey = core.getInput(Inputs.Key, { required: true });
core.saveState(State.CacheKey, primaryKey);
const restoreKeys = core
.getInput(Inputs.RestoreKeys)
.split("\n")
.filter(x => x !== "");
const keys = [primaryKey, ...restoreKeys];
core.debug("Resolved Keys:");
core.debug(JSON.stringify(keys));
if (keys.length > 10) {
core.setFailed(
`Key Validation Error: Keys are limited to a maximum of 10.`
);
return;
}
for (const key of keys) {
if (key.length > 512) {
core.setFailed(
`Key Validation Error: ${key} cannot be larger than 512 characters.`
);
return;
}
const regex = /^[^,]*$/;
async function run(): Promise {
try {
const ms: string = core.getInput('milliseconds')
core.debug(`Waiting ${ms} milliseconds ...`)
core.debug(new Date().toTimeString())
await wait(parseInt(ms, 10))
core.debug(new Date().toTimeString())
core.setOutput('time', new Date().toTimeString())
} catch (error) {
core.setFailed(error.message)
}
}
function fetchResource(kubectl, kind, name) {
const result = kubectl.getResource(kind, name);
if (result == null || !!result.stderr) {
return null;
}
if (!!result.stdout) {
const resource = JSON.parse(result.stdout);
try {
UnsetsClusterSpecficDetails(resource);
return resource;
}
catch (ex) {
core.debug('Exception occurred while Parsing ' + resource + ' in Json object');
core.debug(`Exception:${ex}`);
}
}
return null;
}
exports.fetchResource = fetchResource;
function _isExplicitVersion(versionSpec) {
const c = semver.clean(versionSpec) || '';
core.debug(`isExplicit: ${c}`);
const valid = semver.valid(c) != null;
core.debug(`explicit? ${valid}`);
return valid;
}
function _evaluateVersions(versions, versionSpec) {
async function run() {
const from = core.getInput('fromPhoneNumber');
const to = core.getInput('toPhoneNumber');
const message = core.getInput('message');
const accountSid = core.getInput('TWILIO_ACCOUNT_SID') || process.env.TWILIO_ACCOUNT_SID;
const apiKey = core.getInput('TWILIO_API_KEY') || process.env.TWILIO_API_KEY;
const apiSecret = core.getInput('TWILIO_API_SECRET') || process.env.TWILIO_API_SECRET;
core.debug('Sending SMS');
const client = twilio(apiKey, apiSecret, { accountSid });
const resultMessage = await client.messages.create({
from,
to,
body: message,
});
core.debug('SMS sent!');
core.setOutput('messageSid', resultMessage.sid);
return resultMessage;
}
async function execute() {