Files
tashow-manager/.gitea/workflows/deploy.yml
悠山 47623d6b1e
Some checks failed
Auto Deploy / build-and-deploy (push) Failing after 6s
perf: 优化 CI/CD 流程,使用持久化目录和缓存加速部署
2026-03-02 17:21:08 +08:00

47 lines
1.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Auto Deploy
on:
push:
branches:
- wuxichen # 当前分支
- main
- master
jobs:
build-and-deploy:
runs-on: self-hosted
steps:
- name: Build and Deploy
run: |
# 使用持久化工作目录,避免每次重新克隆
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/
echo "部署成功!"