From 085e62bb86a16890fc2036c7a4404069c8c0f6c7 Mon Sep 17 00:00:00 2001 From: tmshkr Date: Tue, 5 Mar 2024 23:10:10 +0000 Subject: [PATCH] Update dist file --- dist/index.js | 196 ++++++++++++++++++++++++++------------------------ 1 file changed, 102 insertions(+), 94 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6769171..299b0d0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -233942,6 +233942,98 @@ function createApplicationVersion(inputs) { }); } +;// CONCATENATED MODULE: ./src/inputs.ts + +const inputs_fs = __nccwpck_require__(57147); +function getInputs() { + const inputs = { + appName: core.getInput("app_name", { required: true }), + awsRegion: core.getInput("aws_region") || + process.env.AWS_REGION || + process.env.AWS_DEFAULT_REGION, + blueEnv: core.getInput("blue_env", { required: true }), + createEnvironment: core.getBooleanInput("create_environment", { + required: true, + }), + deploy: core.getBooleanInput("deploy", { required: true }), + disableTerminationProtection: core.getBooleanInput("disable_termination_protection"), + enableTerminationProtection: core.getBooleanInput("enable_termination_protection"), + greenEnv: core.getInput("green_env", { required: true }), + minimumHealthColor: mapHealthColorToInt(core.getInput("minimum_health_color", { + required: true, + })), + optionSettings: core.getInput("option_settings") + ? JSON.parse(inputs_fs.readFileSync(core.getInput("option_settings"))) + : undefined, + platformBranchName: core.getInput("platform_branch_name"), + productionCNAME: core.getInput("production_cname", { required: true }), + sourceBundle: core.getInput("source_bundle") || undefined, + stagingCNAME: core.getInput("staging_cname", { required: true }), + swapCNAMEs: core.getBooleanInput("swap_cnames", { required: true }), + templateName: core.getInput("template_name") || undefined, + terminateUnhealthyEnvironment: core.getBooleanInput("terminate_unhealthy_environment", { required: true }), + updateEnvironment: core.getBooleanInput("update_environment", { + required: true, + }), + updateListenerRules: core.getBooleanInput("update_listener_rules", { + required: true, + }), + versionDescription: core.getInput("version_description") || undefined, + versionLabel: core.getInput("version_label") || undefined, + waitForDeployment: core.getBooleanInput("wait_for_deployment", { + required: true, + }), + waitForEnvironment: core.getBooleanInput("wait_for_environment", { + required: true, + }), + waitForTermination: core.getBooleanInput("wait_for_termination", { + required: true, + }), + useDefaultOptionSettings: core.getBooleanInput("use_default_option_settings", { + required: true, + }), + }; + try { + checkInputs(inputs); + } + catch (err) { + core.setFailed(err.message); + throw err; + } + return inputs; +} +function checkInputs(inputs) { + if (!inputs.awsRegion) { + throw new Error("aws_region must be provided"); + } + if (inputs.blueEnv === inputs.greenEnv) { + throw new Error("blue_env and green_env must be different"); + } + if (!inputs.versionLabel && inputs.sourceBundle) { + throw new Error("source_bundle must be provided with a version_label"); + } + if (inputs.productionCNAME === inputs.stagingCNAME) { + throw new Error("production_cname and staging_cname must be different"); + } + if (inputs.optionSettings && !Array.isArray(inputs.optionSettings)) { + throw new Error("option_settings must be an array"); + } +} +function mapHealthColorToInt(healthColor) { + switch (healthColor.toUpperCase()) { + case "GREEN": + return 3; + case "YELLOW": + return 2; + case "RED": + return 1; + case "GREY": + return 0; + default: + throw new Error("Invalid health color"); + } +} + ;// CONCATENATED MODULE: ./src/getEnvironments.ts var getEnvironments_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } @@ -234309,6 +234401,7 @@ var getTargetEnv_awaiter = (undefined && undefined.__awaiter) || function (thisA + function getTargetEnv(inputs) { return getTargetEnv_awaiter(this, void 0, void 0, function* () { const { prodEnv, stagingEnv } = yield getEnvironments(inputs); @@ -234339,24 +234432,13 @@ function getTargetEnv(inputs) { else throw new Error("Target environment is not ready and wait_for_environment is false. Exiting..."); } - switch (targetEnv.Health) { - case "Green": - console.log("Target environment's health is Green."); - return targetEnv; - case "Yellow": - console.log("Target environment's health is Yellow."); - yield terminateEnvironment(inputs, targetEnv); - return null; - case "Red": - console.log("Target environment's health is Red."); - yield terminateEnvironment(inputs, targetEnv); - return null; - case "Grey": - console.log("Target environment's health is Grey."); - yield terminateEnvironment(inputs, targetEnv); - return null; - default: - throw new Error("Target environment is unknown."); + console.log(`Target environment's health is ${targetEnv.Health}.`); + if (mapHealthColorToInt(targetEnv.Health) < inputs.minimumHealthColor) { + yield terminateEnvironment(inputs, targetEnv); + return null; + } + else { + return targetEnv; } }); } @@ -234490,6 +234572,7 @@ var swapCNAMEs_awaiter = (undefined && undefined.__awaiter) || function (thisArg + const swapCNAMEs_core = __nccwpck_require__(42186); function swapCNAMEs(inputs) { return swapCNAMEs_awaiter(this, void 0, void 0, function* () { @@ -234498,7 +234581,7 @@ function swapCNAMEs(inputs) { swapCNAMEs_core.warning("Cannot swap CNAMEs without both environments..."); return; } - if (stagingEnv.Health !== "Green") { + if (mapHealthColorToInt(stagingEnv.Health) < inputs.minimumHealthColor) { throw new Error(`Target environment is not healthy. Cannot swap CNAMEs.`); } if (stagingEnv.Status !== "Ready" || prodEnv.Status !== "Ready") { @@ -234584,81 +234667,6 @@ function setOutputs(targetEnv) { }); } -;// CONCATENATED MODULE: ./src/inputs.ts - -const inputs_fs = __nccwpck_require__(57147); -function getInputs() { - const inputs = { - appName: core.getInput("app_name", { required: true }), - awsRegion: core.getInput("aws_region") || - process.env.AWS_REGION || - process.env.AWS_DEFAULT_REGION, - blueEnv: core.getInput("blue_env", { required: true }), - createEnvironment: core.getBooleanInput("create_environment", { - required: true, - }), - deploy: core.getBooleanInput("deploy", { required: true }), - disableTerminationProtection: core.getBooleanInput("disable_termination_protection"), - enableTerminationProtection: core.getBooleanInput("enable_termination_protection"), - greenEnv: core.getInput("green_env", { required: true }), - optionSettings: core.getInput("option_settings") - ? JSON.parse(inputs_fs.readFileSync(core.getInput("option_settings"))) - : undefined, - platformBranchName: core.getInput("platform_branch_name"), - productionCNAME: core.getInput("production_cname", { required: true }), - sourceBundle: core.getInput("source_bundle") || undefined, - stagingCNAME: core.getInput("staging_cname", { required: true }), - swapCNAMEs: core.getBooleanInput("swap_cnames", { required: true }), - templateName: core.getInput("template_name") || undefined, - terminateUnhealthyEnvironment: core.getBooleanInput("terminate_unhealthy_environment", { required: true }), - updateEnvironment: core.getBooleanInput("update_environment", { - required: true, - }), - updateListenerRules: core.getBooleanInput("update_listener_rules", { - required: true, - }), - versionDescription: core.getInput("version_description") || undefined, - versionLabel: core.getInput("version_label") || undefined, - waitForDeployment: core.getBooleanInput("wait_for_deployment", { - required: true, - }), - waitForEnvironment: core.getBooleanInput("wait_for_environment", { - required: true, - }), - waitForTermination: core.getBooleanInput("wait_for_termination", { - required: true, - }), - useDefaultOptionSettings: core.getBooleanInput("use_default_option_settings", { - required: true, - }), - }; - try { - checkInputs(inputs); - } - catch (err) { - core.setFailed(err.message); - throw err; - } - return inputs; -} -function checkInputs(inputs) { - if (!inputs.awsRegion) { - throw new Error("aws_region must be provided"); - } - if (inputs.blueEnv === inputs.greenEnv) { - throw new Error("blue_env and green_env must be different"); - } - if (!inputs.versionLabel && inputs.sourceBundle) { - throw new Error("source_bundle must be provided with a version_label"); - } - if (inputs.productionCNAME === inputs.stagingCNAME) { - throw new Error("production_cname and staging_cname must be different"); - } - if (inputs.optionSettings && !Array.isArray(inputs.optionSettings)) { - throw new Error("option_settings must be an array"); - } -} - ;// CONCATENATED MODULE: ./src/run.ts if (!process.env.GITHUB_ACTIONS) { (__nccwpck_require__(12437).config)();