# !/bin/bash
echo ""
# 输出当前时间
date --date='0 days ago' "+%Y-%m-%d %H:%M:%S"
echo "-------开始拉取-------"
# web服务器 git 项目路径
gitPath="/www/wwwroot/xxxx"
# 码云项目 SSH 网址 (重点: 千万不要用 https 地址)
gitHttp="git@gitee.com:xxxx"
echo "Web站点路径:$gitPath"
echo "Git路径:$gitHttp"
# 判断项目路径是否存在
if [ -d "$gitPath" ]; then
cd $gitPath
# 判断是否存在git目录
if [ ! -d ".git" ]; then
echo "在该目录下克隆 git"
git clone $gitHttp gittemp
mv gittemp/.git .
rm -rf gittemp
fi
# 拉取最新的项目文件
git reset --hard origin/master
git pull origin master
# 设置目录权限
chown -R www:www $gitPath
echo "-----拉取成功,准备构建-----"
if [ ! -d "node_modules" ]; then
echo "-----安装依赖-----"
npm install
echo "-----安装完成-----"
else
echo "-----不需要安装依赖-----"
fi
echo "-----准备构建-----"
npm run build
echo "-----构建完成-----"
exit
else
echo "该项目路径不存在"
echo "-------拉取失败-------"
exit
fi
webhook前端构建脚本
发布于 2025-02-26 240 次阅读
Comments NOTHING