@@ -233942,6 +233942,98 @@ function createApplicationVersion(inputs) {
233942233942 });
233943233943}
233944233944
233945+ ;// CONCATENATED MODULE: ./src/inputs.ts
233946+
233947+ const inputs_fs = __nccwpck_require__(57147);
233948+ function getInputs() {
233949+ const inputs = {
233950+ appName: core.getInput("app_name", { required: true }),
233951+ awsRegion: core.getInput("aws_region") ||
233952+ process.env.AWS_REGION ||
233953+ process.env.AWS_DEFAULT_REGION,
233954+ blueEnv: core.getInput("blue_env", { required: true }),
233955+ createEnvironment: core.getBooleanInput("create_environment", {
233956+ required: true,
233957+ }),
233958+ deploy: core.getBooleanInput("deploy", { required: true }),
233959+ disableTerminationProtection: core.getBooleanInput("disable_termination_protection"),
233960+ enableTerminationProtection: core.getBooleanInput("enable_termination_protection"),
233961+ greenEnv: core.getInput("green_env", { required: true }),
233962+ minimumHealthColor: mapHealthColorToInt(core.getInput("minimum_health_color", {
233963+ required: true,
233964+ })),
233965+ optionSettings: core.getInput("option_settings")
233966+ ? JSON.parse(inputs_fs.readFileSync(core.getInput("option_settings")))
233967+ : undefined,
233968+ platformBranchName: core.getInput("platform_branch_name"),
233969+ productionCNAME: core.getInput("production_cname", { required: true }),
233970+ sourceBundle: core.getInput("source_bundle") || undefined,
233971+ stagingCNAME: core.getInput("staging_cname", { required: true }),
233972+ swapCNAMEs: core.getBooleanInput("swap_cnames", { required: true }),
233973+ templateName: core.getInput("template_name") || undefined,
233974+ terminateUnhealthyEnvironment: core.getBooleanInput("terminate_unhealthy_environment", { required: true }),
233975+ updateEnvironment: core.getBooleanInput("update_environment", {
233976+ required: true,
233977+ }),
233978+ updateListenerRules: core.getBooleanInput("update_listener_rules", {
233979+ required: true,
233980+ }),
233981+ versionDescription: core.getInput("version_description") || undefined,
233982+ versionLabel: core.getInput("version_label") || undefined,
233983+ waitForDeployment: core.getBooleanInput("wait_for_deployment", {
233984+ required: true,
233985+ }),
233986+ waitForEnvironment: core.getBooleanInput("wait_for_environment", {
233987+ required: true,
233988+ }),
233989+ waitForTermination: core.getBooleanInput("wait_for_termination", {
233990+ required: true,
233991+ }),
233992+ useDefaultOptionSettings: core.getBooleanInput("use_default_option_settings", {
233993+ required: true,
233994+ }),
233995+ };
233996+ try {
233997+ checkInputs(inputs);
233998+ }
233999+ catch (err) {
234000+ core.setFailed(err.message);
234001+ throw err;
234002+ }
234003+ return inputs;
234004+ }
234005+ function checkInputs(inputs) {
234006+ if (!inputs.awsRegion) {
234007+ throw new Error("aws_region must be provided");
234008+ }
234009+ if (inputs.blueEnv === inputs.greenEnv) {
234010+ throw new Error("blue_env and green_env must be different");
234011+ }
234012+ if (!inputs.versionLabel && inputs.sourceBundle) {
234013+ throw new Error("source_bundle must be provided with a version_label");
234014+ }
234015+ if (inputs.productionCNAME === inputs.stagingCNAME) {
234016+ throw new Error("production_cname and staging_cname must be different");
234017+ }
234018+ if (inputs.optionSettings && !Array.isArray(inputs.optionSettings)) {
234019+ throw new Error("option_settings must be an array");
234020+ }
234021+ }
234022+ function mapHealthColorToInt(healthColor) {
234023+ switch (healthColor.toUpperCase()) {
234024+ case "GREEN":
234025+ return 3;
234026+ case "YELLOW":
234027+ return 2;
234028+ case "RED":
234029+ return 1;
234030+ case "GREY":
234031+ return 0;
234032+ default:
234033+ throw new Error("Invalid health color");
234034+ }
234035+ }
234036+
233945234037;// CONCATENATED MODULE: ./src/getEnvironments.ts
233946234038var getEnvironments_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
233947234039 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
234309234401
234310234402
234311234403
234404+
234312234405function getTargetEnv(inputs) {
234313234406 return getTargetEnv_awaiter(this, void 0, void 0, function* () {
234314234407 const { prodEnv, stagingEnv } = yield getEnvironments(inputs);
@@ -234339,24 +234432,13 @@ function getTargetEnv(inputs) {
234339234432 else
234340234433 throw new Error("Target environment is not ready and wait_for_environment is false. Exiting...");
234341234434 }
234342- switch (targetEnv.Health) {
234343- case "Green":
234344- console.log("Target environment's health is Green.");
234345- return targetEnv;
234346- case "Yellow":
234347- console.log("Target environment's health is Yellow.");
234348- yield terminateEnvironment(inputs, targetEnv);
234349- return null;
234350- case "Red":
234351- console.log("Target environment's health is Red.");
234352- yield terminateEnvironment(inputs, targetEnv);
234353- return null;
234354- case "Grey":
234355- console.log("Target environment's health is Grey.");
234356- yield terminateEnvironment(inputs, targetEnv);
234357- return null;
234358- default:
234359- throw new Error("Target environment is unknown.");
234435+ console.log(`Target environment's health is ${targetEnv.Health}.`);
234436+ if (mapHealthColorToInt(targetEnv.Health) < inputs.minimumHealthColor) {
234437+ yield terminateEnvironment(inputs, targetEnv);
234438+ return null;
234439+ }
234440+ else {
234441+ return targetEnv;
234360234442 }
234361234443 });
234362234444}
@@ -234490,6 +234572,7 @@ var swapCNAMEs_awaiter = (undefined && undefined.__awaiter) || function (thisArg
234490234572
234491234573
234492234574
234575+
234493234576const swapCNAMEs_core = __nccwpck_require__(42186);
234494234577function swapCNAMEs(inputs) {
234495234578 return swapCNAMEs_awaiter(this, void 0, void 0, function* () {
@@ -234498,7 +234581,7 @@ function swapCNAMEs(inputs) {
234498234581 swapCNAMEs_core.warning("Cannot swap CNAMEs without both environments...");
234499234582 return;
234500234583 }
234501- if (stagingEnv.Health !== "Green" ) {
234584+ if (mapHealthColorToInt( stagingEnv.Health) < inputs.minimumHealthColor ) {
234502234585 throw new Error(`Target environment is not healthy. Cannot swap CNAMEs.`);
234503234586 }
234504234587 if (stagingEnv.Status !== "Ready" || prodEnv.Status !== "Ready") {
@@ -234584,81 +234667,6 @@ function setOutputs(targetEnv) {
234584234667 });
234585234668}
234586234669
234587- ;// CONCATENATED MODULE: ./src/inputs.ts
234588-
234589- const inputs_fs = __nccwpck_require__(57147);
234590- function getInputs() {
234591- const inputs = {
234592- appName: core.getInput("app_name", { required: true }),
234593- awsRegion: core.getInput("aws_region") ||
234594- process.env.AWS_REGION ||
234595- process.env.AWS_DEFAULT_REGION,
234596- blueEnv: core.getInput("blue_env", { required: true }),
234597- createEnvironment: core.getBooleanInput("create_environment", {
234598- required: true,
234599- }),
234600- deploy: core.getBooleanInput("deploy", { required: true }),
234601- disableTerminationProtection: core.getBooleanInput("disable_termination_protection"),
234602- enableTerminationProtection: core.getBooleanInput("enable_termination_protection"),
234603- greenEnv: core.getInput("green_env", { required: true }),
234604- optionSettings: core.getInput("option_settings")
234605- ? JSON.parse(inputs_fs.readFileSync(core.getInput("option_settings")))
234606- : undefined,
234607- platformBranchName: core.getInput("platform_branch_name"),
234608- productionCNAME: core.getInput("production_cname", { required: true }),
234609- sourceBundle: core.getInput("source_bundle") || undefined,
234610- stagingCNAME: core.getInput("staging_cname", { required: true }),
234611- swapCNAMEs: core.getBooleanInput("swap_cnames", { required: true }),
234612- templateName: core.getInput("template_name") || undefined,
234613- terminateUnhealthyEnvironment: core.getBooleanInput("terminate_unhealthy_environment", { required: true }),
234614- updateEnvironment: core.getBooleanInput("update_environment", {
234615- required: true,
234616- }),
234617- updateListenerRules: core.getBooleanInput("update_listener_rules", {
234618- required: true,
234619- }),
234620- versionDescription: core.getInput("version_description") || undefined,
234621- versionLabel: core.getInput("version_label") || undefined,
234622- waitForDeployment: core.getBooleanInput("wait_for_deployment", {
234623- required: true,
234624- }),
234625- waitForEnvironment: core.getBooleanInput("wait_for_environment", {
234626- required: true,
234627- }),
234628- waitForTermination: core.getBooleanInput("wait_for_termination", {
234629- required: true,
234630- }),
234631- useDefaultOptionSettings: core.getBooleanInput("use_default_option_settings", {
234632- required: true,
234633- }),
234634- };
234635- try {
234636- checkInputs(inputs);
234637- }
234638- catch (err) {
234639- core.setFailed(err.message);
234640- throw err;
234641- }
234642- return inputs;
234643- }
234644- function checkInputs(inputs) {
234645- if (!inputs.awsRegion) {
234646- throw new Error("aws_region must be provided");
234647- }
234648- if (inputs.blueEnv === inputs.greenEnv) {
234649- throw new Error("blue_env and green_env must be different");
234650- }
234651- if (!inputs.versionLabel && inputs.sourceBundle) {
234652- throw new Error("source_bundle must be provided with a version_label");
234653- }
234654- if (inputs.productionCNAME === inputs.stagingCNAME) {
234655- throw new Error("production_cname and staging_cname must be different");
234656- }
234657- if (inputs.optionSettings && !Array.isArray(inputs.optionSettings)) {
234658- throw new Error("option_settings must be an array");
234659- }
234660- }
234661-
234662234670;// CONCATENATED MODULE: ./src/run.ts
234663234671if (!process.env.GITHUB_ACTIONS) {
234664234672 (__nccwpck_require__(12437).config)();
0 commit comments