手动发布比较机械,而且重复比较多,手动容易出错或者误操作,写一个简单的脚本,也能加快效率
新建一个.sh 文件
在 linux 服务器上执行的文件
GIT_HOME=/developer/git-repository/
DEST_PATH=/product/front/
if [ ! -n "$1" ];
then
echo -e "Please input a project name! You can input as follows:"
echo -e "./fe-deploy.sh projectname"
exit
fi
if [ $1 = "projectname" ];
then
echo -e "---------Enter Project--------"
cd $GIT_HOME$1
else
echo -e "Invalid Project Name!"
exit
fi
# clean dist
echo -e "---------Clean Dist--------"
rm -rf ./dist
echo -e "---------Git Pull--------"
git pull
echo -e "---------Yarn Install--------"
yarn
echo -e "---------Yarn Run Dist--------"
yarn run dist
if [ -d "./dist" ];
then
echo -e "---------clean Dest--------"
rm -rf $DEST_PATH/dist
echo -e "---------copy Dest--------"
cp -R ./dist $DEST_PATH/$1/
echo -e "---------Deploy Success--------"
else
echo -e "---------Deploy Fail--------"
fi