Files
doctor-match/.woodpecker.yml

91 lines
3.6 KiB
YAML
Executable File
Raw Permalink 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.
# ============================================
# 天网系统 CI/CD 流水线(Woodpecker CI v3
#
# 流程:push master → 部署测试服(自动)
# deployment → 部署生产服(手动)
# CI修复: branch配置已修正为master
#
# 构建在目标服务器上通过 docker compose --build 完成
# ============================================
steps:
# ── 部署测试服(push 自动触发) ──
- name: deploy-test
image: ubuntu:22.04
environment:
SSH_KEY:
from_secret: SSH_KEY
SSH_KNOWN_HOSTS:
from_secret: SSH_KNOWN_HOSTS
commands:
- DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y openssh-client
- printf '%s' "$SSH_KEY" > /tmp/deploy_key && chmod 600 /tmp/deploy_key
- eval $(ssh-agent -s)
- ssh-add /tmp/deploy_key
- rm -f /tmp/deploy_key
- mkdir -p ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- |
ssh -o StrictHostKeyChecking=no root@192.168.3.157 << 'DEPLOY_TEST'
cd /home/yang/doctor-match-deploy
git pull origin master || true
cd deploy
cp .env .env.bak 2>/dev/null || true
cp -f /tmp/.env.test .env 2>/dev/null || true
docker compose down
docker compose up -d --build
docker compose ps
# --- 前端配置修复(使用相对路径走 nginx 代理)---
FRONTEND_DIR="/home/yang/doctor-match-deploy/frontend-dist"
mkdir -p "$FRONTEND_DIR" 2>/dev/null || true
echo 'window._VBEN_ADMIN_PRO_APP_CONF_={"VITE_GLOB_API_URL":"/api/v1"};Object.freeze(window._VBEN_ADMIN_PRO_APP_CONF_);Object.defineProperty(window,"_VBEN_ADMIN_PRO_APP_CONF_",{configurable:false,writable:false,});' > "$FRONTEND_DIR/_app.config.js" 2>/dev/null || true
echo "=== 测试服部署完成 ==="
DEPLOY_TEST
when:
event:
- push
# ── 部署生产服(手动/deployment 触发) ──
- name: deploy-prod
image: ubuntu:22.04
environment:
SSH_KEY_PROD:
from_secret: SSH_KEY_PROD
SSH_KNOWN_HOSTS_PROD:
from_secret: SSH_KNOWN_HOSTS_PROD
commands:
- echo "=== 部署到生产服 ==="
- DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y openssh-client
- printf '%s' "$SSH_KEY_PROD" > /tmp/deploy_key && chmod 600 /tmp/deploy_key
- eval $(ssh-agent -s)
- ssh-add /tmp/deploy_key
- rm -f /tmp/deploy_key
- mkdir -p ~/.ssh
- echo "$SSH_KNOWN_HOSTS_PROD" > ~/.ssh/known_hosts
- |
ssh -o StrictHostKeyChecking=no root@114.55.171.188 << 'DEPLOY_PROD'
cd /opt/tianwang-order-matching
# 生产服无法访问内网 Gitea,通过公网域名 pull
git remote set-url origin https://liuyang:Liuyang%261991@git.ygaixiao.top/yang/tianwang-order-matching.git
git pull origin master || true
cd deploy
cp .env .env.bak 2>/dev/null || true
cp -f .env.prod .env 2>/dev/null || true
docker compose down
docker compose --env-file .env.prod up -d --build
docker compose ps
# --- 前端配置修复(使用相对路径走 nginx 代理)---
FRONTEND_DIR="/opt/tianwang-order-matching/frontend-dist"
mkdir -p "$FRONTEND_DIR" 2>/dev/null || true
echo 'window._VBEN_ADMIN_PRO_APP_CONF_={"VITE_GLOB_API_URL":"/api/v1"};Object.freeze(window._VBEN_ADMIN_PRO_APP_CONF_);Object.defineProperty(window,"_VBEN_ADMIN_PRO_APP_CONF_",{configurable:false,writable:false,});' > "$FRONTEND_DIR/_app.config.js" 2>/dev/null || true
echo "=== 生产服部署完成 ==="
DEPLOY_PROD
when:
event:
- deployment
- manual