name: Deploy to Production on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Deploy to server uses: appleboy/ssh-action@v1.0.0 with: host: 172.16.74.149 username: atai password: wengewudi666808 port: 22 script: | cd /home/atai/kt-financial-system # 如果目录不存在,克隆仓库 if [ ! -d ".git" ]; then cd /home/atai git clone https://gitea.ktyun.cc/chenjiangjiang/kt-financial-system.git cd kt-financial-system fi # 拉取最新代码 git pull origin main # 停止并删除旧容器 docker-compose down # 构建并启动新容器 docker-compose up -d --build # 清理旧镜像 docker image prune -f # 显示容器状态 docker-compose ps