From a7820c499a9732160a0d672318f315163801c33c Mon Sep 17 00:00:00 2001 From: chu fan Date: Wed, 6 Sep 2023 18:51:59 +0800 Subject: [PATCH] release v0.0.1-alpha.0 --- scripts/.exec | 15 +++++++++------ scripts/bundle | 4 +++- scripts/deploy | 33 +++++++++++++++++++++------------ 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/scripts/.exec b/scripts/.exec index 57204de..b1ef1aa 100755 --- a/scripts/.exec +++ b/scripts/.exec @@ -52,16 +52,18 @@ exports.execShell = async commands => { runCommands=commands } - for (const command of runCommands) { - console.log(`>>>command:\n ${command} \n<<>>command--${count}:\n ${command} \n<<>>> ${scriptCommand} `) // 执行 - await execShell(scriptCommand) + // await execShell(scriptCommand) })() diff --git a/scripts/deploy b/scripts/deploy index 5544ae8..1db9758 100755 --- a/scripts/deploy +++ b/scripts/deploy @@ -12,8 +12,8 @@ const dockerDeployInfo={ repoAddress:"registry.cn-hangzhou.aliyuncs.com/142vip/doc_book", containerName:'408CSFamily', networkName:'service_env_net', - imageName:`${this.repoAddress}:${this.containerName}-${packageVersion}` } +const imageName=`${dockerDeployInfo.repoAddress}:${dockerDeployInfo.containerName}-${packageVersion}` // 支持的命令 const SupportScripts={ @@ -27,31 +27,39 @@ const SupportScripts={ git config --list git commit -m "release v${packageVersion}" ## 部署到github pages - git push -f https://github.com/mmdapl/408CSFamily.git main:pages/github + git push -f https://github.com/mmdapl/408CSFamily.git master:pages/github cd - `, Ali:[ // 容器存在即删除 ` - docker inspect ${dockerDeployInfo.containerName} -f '{{.Name}}' > /dev/null - if [ $? -eq 0 ] ;then + if docker inspect --format='{{.State.Running}}' ${dockerDeployInfo.containerName} >/dev/null 2>&1;then docker rm -f ${dockerDeployInfo.containerName} + exit 0; + else + echo "容器:${dockerDeployInfo.containerName},不存在" + exit 1; fi `, // 镜像存在即删除 ` - if [[ "$(docker images -q ${dockerDeployInfo.imageName} 2> /dev/null)" != "" ]];then - docker rmi ${dockerDeployInfo.imageName} + if [[ "$(docker images -q ${imageName} 2> /dev/null)" != "" ]];then + docker rmi ${imageName} + exit 0; + else + echo -e "镜像:${imageName},不存在" + exit 1; fi `, // 运行容器 ` - docker run -d --name ${dockerDeployInfo.containerName} - -p 7000:80 - --network=${dockerDeployInfo.networkName} - --restart=unless-stopped - --ip=172.30.0.100 - ${dockerDeployInfo.imageName}`, + docker run -d --name ${dockerDeployInfo.containerName} \ + -p 7000:80 \ + --network=${dockerDeployInfo.networkName} \ + --restart=unless-stopped \ + --ip=172.30.0.100 \ + ${imageName} + `, ] } @@ -76,5 +84,6 @@ function getDeployCommand(){ // 执行 ;(async ()=>{ const deployCommand=getDeployCommand() + // console.log(deployCommand) await execShell(deployCommand) })() \ No newline at end of file