#!/bin/bash ### # @Author: Haijun Zhang # @Date: 2022-11-03 09:46:32 # @LastEditTime: 2023-05-26 11:38:09 # @LastEditors: Haijun Zhang # @Description: # @FilePath: \cmc-web\build\deploy.sh ### apps=(cop ams sms cop-console) host=${1:-trunk} app=${2:-all} pnpm build:"${app}" buildConsole() { ssh root@"${host}" /usr/bin/rm -rf /opt/cmp/consoles/csc-web/sub-app/"$1" scp -r ./webs/"${1}"/"${1}" root@"${host}":/opt/cmp/consoles/csc-web/sub-app/"${1}" } if [ "${app}" == 'all' ]; then scp_command='' for console in ${apps[@]}; do if [[ $console == *'-console' ]]; then buildConsole "$console" else scp_command="${scp_command} ./webs/${console}-web/${console}-web" fi done ssh root@"${host}" rm -rf /opt/cmp/consoles/cmc-web/sub-app/* scp -r "${scp_command}" root@"${host}":/opt/cmp/consoles/cmc-web/sub-app elif [[ "${app}" == *"-console" ]]; then buildConsole "$app" elif [ "${app}" != 'main' ]; then ssh root@"${host}" /usr/bin/rm -rf /opt/cmp/consoles/cmc-web/sub-app/"${app}"-web scp -r ./webs/"${app}"-web/"${app}"-web root@"${host}":/opt/cmp/consoles/cmc-web/sub-app/${app}-web fi