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:
@@ -1,12 +1,8 @@
|
|||||||
import { GluegunMenuToolbox } from '@lenne.tech/gluegun-menu'
|
import { GluegunMenuToolbox } from '@lenne.tech/gluegun-menu'
|
||||||
import chalk = require('chalk');
|
import chalk = require('chalk');
|
||||||
import { defaultMenuSettings } from '../../../globals';
|
import { defaultMenuSettings, sleep } from '../../../globals';
|
||||||
const { AutoComplete } = require('enquirer');
|
const { AutoComplete } = require('enquirer');
|
||||||
|
|
||||||
const sleep = (milliseconds) => {
|
|
||||||
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'parameterstore',
|
name: 'parameterstore',
|
||||||
alias: ['ps'],
|
alias: ['ps'],
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import { GluegunMenuToolbox } from '@lenne.tech/gluegun-menu'
|
|||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const { AutoComplete, Input, Confirm } = require('enquirer');
|
const { AutoComplete, Input, Confirm } = require('enquirer');
|
||||||
import { Octokit } from "@octokit/core";
|
import { Octokit } from "@octokit/core";
|
||||||
import { defaultMenuSettings, getCurrentBranch, getSettings } from '../../../../globals';
|
import { exit } from 'process';
|
||||||
|
import { defaultMenuSettings, getCurrentBranch, getSettings, sleep } from '../../../../globals';
|
||||||
|
|
||||||
type Stack = {
|
type Stack = {
|
||||||
name: string
|
name: string
|
||||||
@@ -143,6 +144,35 @@ module.exports = {
|
|||||||
print.fancy(`Running [${chalk.yellow(cmd)}] in folder [${`${config.photowall_repo}/cloudformation/`}]`);
|
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});
|
const output = await system.run(cmd, {cwd: `${config.photowall_repo}/cloudformation/`, trim: true});
|
||||||
print.fancy(output);
|
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) {
|
} catch (e) {
|
||||||
@@ -151,6 +181,8 @@ module.exports = {
|
|||||||
|
|
||||||
if (toolbox.fromMenu()) {
|
if (toolbox.fromMenu()) {
|
||||||
await toolbox.menu.showMenu('deployment testservers', defaultMenuSettings)
|
await toolbox.menu.showMenu('deployment testservers', defaultMenuSettings)
|
||||||
|
} else {
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,3 +65,7 @@ export const confirmMessage = async (message: string) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const sleep = (milliseconds) => {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user