小目标:每次 git 提交后,不用人工打包。简单写了一个bash 脚本,如下:
#!/bin/bash
cd $(dirname $0)
cd ../
[ ! -d logs ] && mkdir logs
path=`pwd`
file=$path"/logs/vue_auto_ark.log"
ps=`ps -ef|grep -v grep|grep vue_auto_ark|wc -l`
day=`date "+%Y-%m-%d"`
minute=`date "+%k:%M"`
echo "exe time:$day $minute" >> $file
echo $ps >> $file
if [ $ps -gt 2 ];then
echo "vue runing" >> $file
exit
fi
source /etc/profile
cd /data/www/ark
git pull
ws=`find /data/www/ark/ -type f -mmin -3|grep -v node_modules|grep -v .git|grep -v dist/|wc -l`
if [ $ws -gt 0 ];then
echo "yarn build " >> $file
yarn install
yarn build
else
echo "nothing do" >> $file
fi
暂定是 每3分钟自动执行一次 (crontab 部署)
*/3 * * * * bash /root/bin/vue_auto_ark.sh
适用于研发测试服务器。正式环境 还是人工控制安全。