Files
check_in/.gitea/workflows/deploy.yml
Workflow config file is invalid. Please check your config file: yaml: line 56: could not find expected ':'
jeremygan2021 3367f0dadd actino
2026-03-20 16:23:46 +08:00

70 lines
2.1 KiB
YAML
Raw 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.
name: 部署到服务器
on:
push:
branches: [main, master]
workflow_dispatch:
env:
TARGET_DIR: /home/quant/data/dev/checkin
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: 安装 sshpass
run: |
sudo apt-get update
sudo apt-get install -y sshpass
- name: 在服务器上部署
env:
SERVER_HOST: 6.6.6.66
SERVER_USER: quant
SERVER_PASSWORD: 123quant-speed
SERVER_PORT: 22
TARGET_DIR: /home/quant/data/dev/checkin
run: |
sshpass -p "$SERVER_PASSWORD" ssh -p "$SERVER_PORT" -o StrictHostKeyChecking=no "${SERVER_USER}@${SERVER_HOST}" << 'EOF'
set -e
run_sudo() {
echo "$SERVER_PASSWORD" | sudo -S -p '' "$@"
}
echo "===== 切换到目标目录: $TARGET_DIR ====="
cd $TARGET_DIR || {
echo "错误:目录 $TARGET_DIR 不存在!"
exit 1
}
echo -e "\n===== 停止并清理 Docker ====="
run_sudo docker compose down || true
echo -e "\n===== 拉取 Git 代码 ====="
if ! git pull; then
echo "警告Git pull 失败,尝试强制同步远程代码..."
git fetch --all
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
git reset --hard origin/$CURRENT_BRANCH
git pull
fi
echo -e "\n===== 配置环境变量 ====="
cat > backend/.env <<'ENVEOF'
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_APP_KEY=6eOX7N3tKE0fDwb
DASHSCOPE_API_KEY=sk-84e9eef24a274f568d4fa15c97556c9f
ENVEOF
echo -e "\n===== 启动 Docker 容器 ====="
run_sudo docker compose up -d --build
echo -e "\n===== 操作完成!====="
EOF