From 80ab95e3a58d62aeaf438ceb97f8cdac6663991a Mon Sep 17 00:00:00 2001 From: jeremygan2021 Date: Fri, 13 Feb 2026 13:51:26 +0800 Subject: [PATCH] action --- .gitea/workflows/deploy.yaml | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .gitea/workflows/deploy.yaml diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..66e685f --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,67 @@ +name: Deploy and Monitor Host Message + +on: + push: + branches: + - main + schedule: + - cron: '0 */3 * * *' + +jobs: + deploy: + if: github.event_name == 'push' + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Copy Files to Server + uses: appleboy/scp-action@master + with: + host: 6.6.6.66 + username: quant + password: ${{ secrets.DEPLOY_PASSWORD }} + source: ".,!**/.git/**,!**/.trae/**,!**/.vscode/**,!**/logs/**,!**/__pycache__/**,!**/*.md" + target: "~/host_message" + + - name: Setup and Start Application + uses: appleboy/ssh-action@master + with: + host: 6.6.6.66 + username: quant + password: ${{ secrets.DEPLOY_PASSWORD }} + script: | + cd ~/host_message + + # 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-latest + steps: + - name: Periodic Health Check + uses: appleboy/ssh-action@master + with: + host: 6.6.6.66 + username: quant + password: ${{ secrets.DEPLOY_PASSWORD }} + script: | + cd ~/host_message + + # Run start.sh which includes health check logic + # If app is down or unhealthy, it will restart it + ./start.sh