3296: now starts the codepipeline after stack update through pwcli (#17)

* now starts the codepipeline after stack update through pwcli

* cleanup
This commit is contained in:
Arwid Thornström
2023-02-03 09:11:20 +01:00
committed by GitHub
parent b338de406c
commit 258e0b2dde
3 changed files with 38 additions and 6 deletions
@@ -1,12 +1,8 @@
import { GluegunMenuToolbox } from '@lenne.tech/gluegun-menu'
import chalk = require('chalk');
import { defaultMenuSettings } from '../../../globals';
import { defaultMenuSettings, sleep } from '../../../globals';
const { AutoComplete } = require('enquirer');
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
module.exports = {
name: 'parameterstore',
alias: ['ps'],
@@ -2,7 +2,8 @@ import { GluegunMenuToolbox } from '@lenne.tech/gluegun-menu'
const chalk = require('chalk');
const { AutoComplete, Input, Confirm } = require('enquirer');
import { Octokit } from "@octokit/core";
import { defaultMenuSettings, getCurrentBranch, getSettings } from '../../../../globals';
import { exit } from 'process';
import { defaultMenuSettings, getCurrentBranch, getSettings, sleep } from '../../../../globals';
type Stack = {
name: string
@@ -143,6 +144,35 @@ module.exports = {
print.fancy(`Running [${chalk.yellow(cmd)}] in folder [${`${config.photowall_repo}/cloudformation/`}]`);
const output = await system.run(cmd, {cwd: `${config.photowall_repo}/cloudformation/`, trim: true});
print.fancy(output);
// Check the status
const spinner = print.spin(`Waiting for stack to update`);
let currentStackStatus = "";
while (currentStackStatus !== "UPDATE_COMPLETE") {
const stackCmd = `aws cloudformation describe-stacks --stack-name photowall-${stacksuffix}`;
const response = await system.run(stackCmd, {trim: true});
const stackData = JSON.parse(response);
currentStackStatus = stackData.Stacks[0].StackStatus;
switch (currentStackStatus) {
case "UPDATE_IN_PROGRESS":
spinner.text = `[${chalk.red(currentStackStatus)}]: Updating the stack`;
case "UPDATE_COMPLETE_CLEANUP_IN_PROGRESS":
spinner.text = `[${chalk.yellow(currentStackStatus)}]: Almost done, cleanup in progress`;
case "UPDATE_COMPLETE":
spinner.text = `[${chalk.green(currentStackStatus)}]: Update complete`;
break;
}
if (currentStackStatus !== 'UPDATE_COMPLETE') {
await sleep(1000);
}
}
spinner.text = `Will start the pipeline now [${chalk.yellow(`photowall-${stacksuffix}Pipeline`)}]`;
const runPipelineCmd = `aws codepipeline start-pipeline-execution --name photowall-${stacksuffix}Pipeline`;
await system.run(runPipelineCmd);
await sleep(2000);
spinner.stop();
print.fancy('Pipeline started, bye! 🚀');
}
} catch (e) {
@@ -151,6 +181,8 @@ module.exports = {
if (toolbox.fromMenu()) {
await toolbox.menu.showMenu('deployment testservers', defaultMenuSettings)
} else {
exit();
}
}
}
+4
View File
@@ -65,3 +65,7 @@ export const confirmMessage = async (message: string) => {
return false;
}
};
export const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}