name: Deploy and Monitor Host Message on: push: branches: - main schedule: - cron: '0 */3 * * *' jobs: deploy: if: github.event_name == 'push' runs-on: ubuntu steps: - name: Checkout Code uses: https://gitea.com/actions/checkout@v3 - name: Copy Files to Server uses: appleboy/scp-action@master with: host: 6.6.6.66 username: quant password: 123quant-speed source: ".,!**/.git/**,!**/.trae/**,!**/.vscode/**,!**/logs/**,!**/__pycache__/**,!**/*.md" target: "/home/quant/data/dev/host_message-main/" - name: Setup and Start Application uses: https://gitea.com/actions/appleboy-ssh-action@v1 with: host: 6.6.6.66 username: quant password: 123quant-speed script: | cd /home/quant/data/dev/host_message-main/ # Ensure python dependencies are installed # Check if pip3 exists, otherwise use pip PIP_CMD="pip" if command -v pip3 &> /dev/null; then PIP_CMD="pip3" fi echo "Installing dependencies using $PIP_CMD..." $PIP_CMD install -r requirements.txt # Make sure start script is executable chmod +x start.sh # Run start script (handles start/restart) ./start.sh monitor: if: github.event_name == 'schedule' runs-on: ubuntu-22.04 steps: - name: Periodic Health Check uses: https://gitea.com/actions/appleboy-ssh-action@v1 with: host: 6.6.6.66 username: quant password: ${{ secrets.DEPLOY_PASSWORD }} script: | cd /home/quant/data/dev/host_message-main/ # Run start.sh which includes health check logic # If app is down or unhealthy, it will restart it ./start.sh