45 lines
1.3 KiB
YAML
45 lines
1.3 KiB
YAML
name: Deploy to Server
|
||
|
||
on:
|
||
push:
|
||
branches:
|
||
- main
|
||
- master
|
||
|
||
jobs:
|
||
deploy:
|
||
runs-on: ubuntu
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v3
|
||
|
||
# 建议在 Gitea 仓库设置中配置 Secrets,而不是直接写在文件中
|
||
# SERVER_HOST, SERVER_USER, SERVER_PASSWORD
|
||
- name: Copy files to server
|
||
uses: appleboy/scp-action@v0.1.7
|
||
with:
|
||
host: "6.6.6.66"
|
||
username: "quant-speed"
|
||
password: "123quant-speed"
|
||
source: "."
|
||
target: "/home/quant-speed/luna2025"
|
||
# 排除不需要上传的文件
|
||
exclude: ".git,.github,.gitea,.trae,__pycache__,*.pyc,*.pyo,*.pyd,.DS_Store"
|
||
|
||
- name: Deploy on server
|
||
uses: appleboy/ssh-action@v1.0.3
|
||
with:
|
||
host: "6.6.6.66"
|
||
username: "quant-speed"
|
||
password: "123quant-speed"
|
||
script: |
|
||
# 进入项目目录
|
||
cd /home/quant-speed/luna2025
|
||
|
||
# 停止容器并删除同名镜像
|
||
# --rmi local: 删除服务构建的镜像
|
||
echo "123quant-speed" | sudo -S docker compose down --rmi local
|
||
|
||
# 启动服务
|
||
echo "123quant-speed" | sudo -S docker compose up -d
|