diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..3ae4cb6 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,46 @@ +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 }} + + # 安装依赖 + echo "安装依赖..." + pnpm install + + # 构建项目 + echo "构建项目..." + pnpm build + + # 部署到服务器 + echo "部署到服务器..." + rsync -av --delete dist/ /home/1panel/www/sites/admin.petshy.tashowz.com/index/ + + echo "部署成功!" diff --git a/public/test.txt b/public/test.txt new file mode 100644 index 0000000..496d6e2 --- /dev/null +++ b/public/test.txt @@ -0,0 +1,2 @@ +CI/CD Test - Deployed at 2026-03-02 16:23 +This file is used to verify automatic deployment is working.