From 0a18e7330b183be60cad0ccbf0747303c81506cc Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 5 May 2023 11:41:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=8E=20ci(=E8=84=9A=E6=9C=AC):=20dist?= =?UTF-8?q?=E5=A4=8D=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pushdist.sh | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100755 pushdist.sh diff --git a/pushdist.sh b/pushdist.sh new file mode 100755 index 000000000..101a8b408 --- /dev/null +++ b/pushdist.sh @@ -0,0 +1,101 @@ +#!/bin/sh +if [ $# != 1 ] ; then + echo "需要1个参数" + exit 1; +fi + +port=22 +env=${1} +sshAddr=() +buildAddr='' + +if [ ${1} == 'alpha' ] ; then + sshAddr=( "zyzalpha") + buildAddr="zyzdev" + port=22 + env='alpha' +elif [ ${1} == 'zy' ] ; then + sshAddr=( "yjz-zy-game1" "yjz-zy-game2" "yjz-zy-game3" "yjz-zy-game4" "yjz-zy-game5" "yjz-zy-game6" "yjz-zy-game7" "yjz-zy-game8" "yjz-zy-game9" "yjz-zy-game10") + buildAddr="yjz-zy-web1" + port=22 + env='zy' +elif [ ${1} == 'ch' ] ; then + sshAddr=("yjz-ch-game1" "yjz-ch-game2" "yjz-ch-game3" "yjz-ch-game4" "yjz-ch-game5" "yjz-ch-game6") + buildAddr="yjz-ch-web1" + port=22 + env='ch' +else + echo "需要一个参数指明服务器" + exit 1; +fi + +echo "|*********************|\n" + +if branch=$(git symbolic-ref --short -q HEAD) +then + echo "git on branch $branch \n" +else + echo "git not on any branch \n" +fi +echo "|*********************|\n" + +echo "and config.json is: \n" +node ./config.js ${env} ${1} +cat './game-server/config.json' +echo "\n" +echo "|*********************|\n" + +echo "and server_const is \n" +cat './shared/resource/jsons/server_const.json' | grep DEBUG_PAY +cat './shared/resource/jsons/server_const.json' | grep DEBUG_TIME +cat './shared/resource/jsons/server_const.json' | grep CHECK_WORD +cat './shared/resource/jsons/server_const.json' | grep CAN_PAY +cat './shared/resource/jsons/server_const.json' | grep SKIP_ENCODE +echo "\n" +echo "|*********************|" + +read -r -p "Are You Sure? [Y/n]" input + +case $input in + [yY][eE][sS]|[yY]) + destUrl='root@'${buildAddr}':/root/zyz/' + echo $destUrl + rsync -av --include '.babelrc' --include '.eslintrc.js' --exclude-from='exclude-file.txt' --progress --inplace --no-owner --no-group --rsh='ssh -p'${port} . ${destUrl} + + ssh $buildAddr " + cd /root/zyz/game-server + npm run build + tar -zcvf dist.tar.gz dist + exit + " + + mkdir ~/pushdist + scp root@$buildAddr:/root/zyz/game-server/dist.tar.gz ~/pushdist/dist.tar.gz + + length=${#sshAddr[@]} + int=1 + while(( $int<=$length )) + do + addr=${sshAddr[$int-1]} + scp ~/pushdist/dist.tar.gz root@$addr:/root/zyz/game-server/dist.tar.gz + ssh $addr " + cd /root/zyz/game-server + tar -zxvf dist.tar.gz + exit + " + let "int++" + done + + ;; + [nN][oO]|[nN]) + echo "No" + ;; + *) + echo "Invalid input" + ;; +esac + +git checkout ./game-server/config.json +git checkout ./gm-server/config/env +git checkout ./web-server/config/env +git checkout ./web-server/config/sshHost.ts