perf: 优化 CI/CD 流程,使用持久化目录和缓存加速部署
Some checks failed
Auto Deploy / build-and-deploy (push) Failing after 6s
Some checks failed
Auto Deploy / build-and-deploy (push) Failing after 6s
This commit is contained in:
@@ -14,12 +14,33 @@ jobs:
|
||||
steps:
|
||||
- name: Build and Deploy
|
||||
run: |
|
||||
cd /tmp
|
||||
rm -rf tashow-build
|
||||
git clone -b ${{ github.ref_name }} http://gitea.tashowz.com/tashow/tashow-manager.git tashow-build
|
||||
cd tashow-build
|
||||
pnpm install
|
||||
# 使用持久化工作目录,避免每次重新克隆
|
||||
WORK_DIR="/root/tashow-deploy"
|
||||
|
||||
# 首次运行时克隆代码
|
||||
if [ ! -d "$WORK_DIR" ]; then
|
||||
echo "首次部署,克隆代码..."
|
||||
git clone http://gitea.tashowz.com/tashow/tashow-manager.git $WORK_DIR
|
||||
fi
|
||||
|
||||
cd $WORK_DIR
|
||||
|
||||
# 更新代码到最新版本
|
||||
echo "更新代码..."
|
||||
git fetch origin
|
||||
git checkout ${{ github.ref_name }}
|
||||
git reset --hard origin/${{ github.ref_name }}
|
||||
|
||||
# 安装依赖(pnpm 会自动利用缓存)
|
||||
echo "安装依赖..."
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
# 构建项目
|
||||
echo "构建项目..."
|
||||
pnpm build
|
||||
|
||||
# 部署到服务器
|
||||
echo "部署到服务器..."
|
||||
rsync -av --delete dist/ /home/1panel/www/sites/admin.petshy.tashowz.com/index/
|
||||
rm -rf /tmp/tashow-build
|
||||
echo "Deployed successfully!"
|
||||
|
||||
echo "部署成功!"
|
||||
|
||||
Reference in New Issue
Block a user