From 908b40aa1f7fc342b990c7a412048227426d6c5e Mon Sep 17 00:00:00 2001 From: openclaw Date: Tue, 9 Jun 2026 13:25:48 -0600 Subject: [PATCH] fix(deploy): SSH into server to deploy instead of local rsync; add rsync install --- .gitea/workflows/deploy.yml | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 84122c4..770b401 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -66,6 +66,9 @@ jobs: MINIMAX_BASE_URL: ${{ secrets.MINIMAX_BASE_URL }} run: npm run build + - name: Install rsync + run: sudo apt-get update && sudo apt-get install -y rsync + - name: Deploy env: DATABASE_URL: ${{ secrets.DATABASE_URL }} @@ -104,9 +107,19 @@ jobs: MINIMAX_API_KEY: ${{ secrets.MINIMAX_API_KEY }} MINIMAX_BASE_URL: ${{ secrets.MINIMAX_BASE_URL }} CRON_SECRET: ${{ secrets.CRON_SECRET }} + SERVER_SSH_KEY: ${{ secrets.SERVER_SSH_KEY }} run: | + set -e APP_DIR=/home/tyler/route-commerce + # Add server SSH host key if provided + if [ -n "$SERVER_SSH_KEY" ]; then + mkdir -p ~/.ssh + echo "$SERVER_SSH_KEY" >> ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + ssh-keyscan route.crispygoat.com >> ~/.ssh/known_hosts 2>/dev/null + fi + # Write production env file { printf "DATABASE_URL=%s\n" "$DATABASE_URL" @@ -147,22 +160,13 @@ jobs: printf "CRON_SECRET=%s\n" "$CRON_SECRET" } > $APP_DIR/.env.production - # Sync build output and required files - rsync -a --delete .next/ $APP_DIR/.next/ - rsync -a --delete public/ $APP_DIR/public/ - cp package.json $APP_DIR/ - cp next.config.ts $APP_DIR/ 2>/dev/null || true + # Sync build output and required files to server + rsync -a --delete .next/ tyler@route.crispygoat.com:$APP_DIR/.next/ + rsync -a --delete public/ tyler@route.crispygoat.com:$APP_DIR/public/ + rsync $APP_DIR/package.json tyler@route.crispygoat.com:$APP_DIR/ + rsync next.config.ts tyler@route.crispygoat.com:$APP_DIR/ 2>/dev/null || true - # Install production deps only - cd $APP_DIR - npm install --omit=dev - - # Start or restart PM2 - if pm2 describe route-commerce > /dev/null 2>&1; then - pm2 restart route-commerce - else - pm2 start npm --name route-commerce -- start -- -p 3100 - pm2 save - fi + # Install production deps and restart on server + ssh tyler@route.crispygoat.com "cd $APP_DIR && npm install --omit=dev && pm2 restart route-commerce || pm2 start npm --name route-commerce -- start -- -p 3100 && pm2 save" echo "Deployed successfully"