Files
market_page/.gitea/workflows/deploy.yaml
jeremygan2021 a456c0b9a2
All checks were successful
Deploy to Server / deploy (push) Successful in 23s
action
2026-02-13 01:50:02 +08:00

44 lines
1.4 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: Deploy to Server
on: [push]
jobs:
deploy:
runs-on: ubuntu
steps:
- name: Deploy using SSH
uses: appleboy/ssh-action@v1.0.3
with:
host: 6.6.6.66
username: quant
password: 123quant-speed
script: |
TARGET_DIR="/home/quant/data/dev/market_page"
SUDO_PASSWORD="123quant-speed"
# 1. 切换到目标目录
echo "===== 切换到目标目录: $TARGET_DIR ====="
cd $TARGET_DIR || {
echo "错误:目录 $TARGET_DIR 不存在!"
exit 1
}
# 2. 停止并移除 Docker 容器
echo -e "\n===== 停止 Docker 容器 ====="
echo $SUDO_PASSWORD | sudo -S docker compose down
# 3. 删除 Docker 镜像
echo -e "\n===== 删除 Docker 镜像 ====="
echo $SUDO_PASSWORD | sudo -S docker compose down --rmi all
# 4. 拉取 Git 最新代码
echo -e "\n===== 拉取 Git 代码 ====="
git pull || {
echo "警告Git pull 失败(可能是本地有未提交的修改),脚本继续执行..."
}
# 5. 重新启动 Docker 容器
echo -e "\n===== 启动 Docker 容器 ====="
echo $SUDO_PASSWORD | sudo -S docker compose up -d
echo -e "\n===== 操作完成!====="