From 00e7d34b03c0d5cc89ad94cf314b800546c295ac Mon Sep 17 00:00:00 2001 From: sun <3371392206@qq.com> Date: Sun, 10 May 2026 20:04:18 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=B7=BB=E5=8A=A0Gitea=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E7=94=A8=E4=BA=8EGo=E9=A1=B9=E7=9B=AE=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E5=88=B0=E5=AE=9D=E5=A1=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加CI/CD工作流配置,实现代码推送时自动构建Go项目并部署到宝塔服务器 包含环境安装、项目编译、进程管理和部署重启步骤 --- .gitea/workflows/deploy.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..a8840dd --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,36 @@ +name: Go CI/CD Deploy to Baota + +on: + push: + branches: [ main, master ] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: 拉取代码 + uses: actions/checkout@v4 + + - name: 安装 Go 环境 + uses: actions/setup-go@v5 + with: + go-version: 1.22 + + - name: 编译 Go 项目 + run: | + # 静态编译,无依赖,适合 Linux 部署 + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app main.go + + - name: 部署到宝塔项目目录并重启服务 + run: | + # 1. 停止旧进程 + pkill -f Volcano-Engine-TTS-UI || true + + # 2. 复制新程序到项目目录 + cp ./app /www/wwwroot/Volcano-Engine-TTS-UI/ + + # 3. 赋予执行权限 + chmod +x /www/wwwroot/Volcano-Engine-TTS-UI/app + + # 4. 启动新进程(后台运行) + nohup /www/wwwroot/Volcano-Engine-TTS-UI/app > /www/wwwroot/Volcano-Engine-TTS-UI/app.log 2>&1 &