Files
Scoring-System/.gitea/workflows/deploy.yaml
爽哒哒 65a03fb761
All checks were successful
Deploy to Server / deploy (push) Successful in 19s
修复工作流:支持非git目录部署
2026-03-21 00:16:06 +08:00

66 lines
2.3 KiB
YAML

name: Deploy to Server
on: [push]
jobs:
deploy:
runs-on: ubuntu
steps:
- name: Deploy using SSH
uses: https://gitea.com/actions/appleboy-ssh-action@v1.0.3
with:
host: 6.6.6.66
username: quant
password: 123quant-speed
script: |
TARGET_DIR="/home/quant/data/dev/deploy"
REPO_URL="https://gitea.tangledup-ai.com/quant-speed-AI/Scoring-System.git"
BRANCH="main"
SUDO_PASSWORD="123quant-speed"
# 1. 创建目标目录
echo "===== 创建目标目录: $TARGET_DIR ====="
sudo mkdir -p $TARGET_DIR
# 2. 检查是否是 git 仓库
echo "===== 检查 git 仓库 ====="
cd $TARGET_DIR
if [ ! -d ".git" ]; then
echo "目录不是 git 仓库,将进行克隆..."
sudo rm -rf $TARGET_DIR/*
sudo git clone -b $BRANCH $REPO_URL $TARGET_DIR
else
echo "已是 git 仓库,执行 pull..."
sudo git pull origin $BRANCH
fi
# 3. 停止并移除 Docker 容器
echo -e "\n===== 停止并清理 Docker ====="
cd $TARGET_DIR
echo $SUDO_PASSWORD | sudo -S docker compose down
# 4. 创建/更新 .env 文件
echo -e "\n===== 配置环境变量 ====="
cat > backend/.env <<EOF
# Database Configuration
DB_NAME=scoring
DB_USER=quant-speed
DB_PASSWORD=123quant-speed
DB_HOST=6.6.6.66
DB_PORT=5432
# Aliyun OSS Configuration
ALIYUN_ACCESS_KEY_ID=LTAI5tE62GW8MKyoEaotzxXk
ALIYUN_ACCESS_KEY_SECRET=Zdzqo1fgj57DxxioXOotNKhJdSfVQW
ALIYUN_OSS_ENDPOINT=https://oss-cn-shanghai.aliyuncs.com
ALIYUN_OSS_BUCKET_NAME=tangledup-ai-staging
ALIYUN_OSS_INTERNAL_ENDPOINT=https://oss-cn-shanghai-internal.aliyuncs.com
# Aliyun Tingwu Configuration
ALIYUN_TINGWU_APP_KEY=6eOX7N3tKE0fDwb
DASHSCOPE_API_KEY=sk-84e9eef24a274f568d4fa15c97556c9f
EOF
# 5. 重新启动 Docker 容器
echo -e "\n===== 启动 Docker 容器 ====="
echo $SUDO_PASSWORD | sudo -S docker compose up -d --build
echo -e "\n===== 操作完成!====="