64 lines
2.1 KiB
YAML
64 lines
2.1 KiB
YAML
name: Deploy to Server
|
|
on: [push]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu
|
|
steps:
|
|
- name: Checkout code
|
|
uses: https://gitea.com/actions/checkout@v4
|
|
|
|
- name: Install sshpass
|
|
run: apt-get install -y sshpass rsync
|
|
|
|
- name: Copy code to server
|
|
run: |
|
|
sshpass -p "123quant-speed" rsync -avz --delete \
|
|
--exclude='.git' \
|
|
--exclude='backend/.env' \
|
|
--exclude='backend/media/' \
|
|
-e "ssh -o StrictHostKeyChecking=no" \
|
|
./ quant@6.6.6.66:/home/quant/data/dev/deploy/
|
|
|
|
- name: Deploy on server via 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"
|
|
SUDO_PASSWORD="123quant-speed"
|
|
|
|
cd $TARGET_DIR
|
|
|
|
# 1. 停止并移除 Docker 容器
|
|
echo "===== 停止并清理 Docker ====="
|
|
echo $SUDO_PASSWORD | sudo -S docker compose down
|
|
|
|
# 2. 创建/更新 .env 文件
|
|
echo "===== 配置环境变量 ====="
|
|
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
|
|
|
|
# 3. 重新启动 Docker 容器
|
|
echo "===== 启动 Docker 容器 ====="
|
|
echo $SUDO_PASSWORD | sudo -S docker compose up -d --build
|
|
|
|
echo "===== 操作完成!====="
|