From 8669ee3366145f3bdfada5451e50d8eb89339338 Mon Sep 17 00:00:00 2001 From: iDefineHD Date: Sun, 11 Jan 2026 00:30:19 +0000 Subject: [PATCH] Remove manual workflow trigger --- .gitea/workflows/deploy.yml | 55 +++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index c02fb25..c137ca5 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -11,6 +11,24 @@ jobs: runs-on: ubuntu-latest steps: + # ------------------------- + # DEBUG: Verify workflow trigger & secrets + # ------------------------- + - name: Debug Info + run: | + echo "🟒 Workflow triggered!" + echo "Branch: $GITHUB_REF" + echo "Commit: $GITHUB_SHA" + echo "Actor: $GITHUB_ACTOR" + echo "Repository: $GITHUB_REPOSITORY" + echo "Server host secret set? $(if [ -z '${{ secrets.SERVER_HOST }}' ]; then echo '❌'; else echo 'βœ…'; fi)" + echo "Server user secret set? $(if [ -z '${{ secrets.SERVER_USER }}' ]; then echo '❌'; else echo 'βœ…'; fi)" + echo "Server password secret set? $(if [ -z '${{ secrets.SERVER_PASSWORD }}' ]; then echo '❌'; else echo 'βœ…'; fi)" + echo "Runner OS: $RUNNER_OS" + + # ------------------------- + # Checkout code + # ------------------------- - name: Checkout code uses: actions/checkout@v4 @@ -37,6 +55,9 @@ jobs: VITE_API_URL: https://api.turbotrades.dev VITE_WS_URL: https://ws.turbotrades.dev + # ------------------------- + # Deploy via SSH + # ------------------------- - name: Deploy via SSH (Gitea + password) uses: appleboy/ssh-action@v1.0.0 with: @@ -45,20 +66,14 @@ jobs: password: ${{ secrets.SERVER_PASSWORD }} port: ${{ secrets.SERVER_PORT || 22 }} script: | - echo "πŸš€ Starting deployment to turbotrades.dev..." + echo "πŸš€ Starting deployment..." - # Ensure directories exist mkdir -p /root/ttbackend /root/ttbackend/logs /var/www/html/turbotrades - cd /root/ttbackend - # Stop backend if running - echo "⏸️ Stopping backend..." pm2 stop turbotrades-backend || echo "Backend not running" pm2 delete turbotrades-backend || true - # Backup current version - echo "πŸ’Ύ Creating backup..." if [ -d "/root/ttbackend-backup" ]; then rm -rf /root/ttbackend-backup-old mv /root/ttbackend-backup /root/ttbackend-backup-old @@ -66,55 +81,45 @@ jobs: mkdir -p /root/ttbackend-backup rsync -a --delete /root/ttbackend/ /root/ttbackend-backup/ || true - # Pull latest code via HTTPS (password auth) if [ -d ".git" ]; then - echo "πŸ“₯ Pulling latest code..." git fetch origin git reset --hard origin/main git clean -fd else - echo "πŸ“₯ Cloning repository..." cd /root rm -rf ttbackend git clone https://username:${{ secrets.SERVER_PASSWORD }}@git.turbotrades.dev/iDefineHD/TurboTrades.git ttbackend cd ttbackend fi - # Install backend dependencies - echo "πŸ“¦ Installing backend dependencies..." npm ci --production - - # Build frontend - echo "🎨 Building frontend..." cd frontend npm ci npm run build - # Deploy frontend - echo "πŸš€ Deploying frontend..." rm -rf /var/www/html/turbotrades/* cp -r dist/* /var/www/html/turbotrades/ chown -R www-data:www-data /var/www/html/turbotrades chmod -R 755 /var/www/html/turbotrades - # Start backend cd /root/ttbackend - echo "▢️ Starting backend..." pm2 start ecosystem.config.js --env production pm2 save - echo "βœ… Deployment complete!" pm2 list + # ------------------------- + # Health Check + # ------------------------- - name: Health Check run: | - echo "⏳ Waiting for services to start..." sleep 15 - echo "πŸ₯ Checking backend..." curl -f https://api.turbotrades.dev/api/health || echo "⚠️ Backend health check failed" - echo "πŸ₯ Checking frontend..." curl -f https://turbotrades.dev || echo "⚠️ Frontend check failed" + # ------------------------- + # Notifications + # ------------------------- - name: Notify Success if: success() run: | @@ -138,12 +143,10 @@ jobs: password: ${{ secrets.SERVER_PASSWORD }} port: ${{ secrets.SERVER_PORT || 22 }} script: | - echo "πŸ”„ Rolling back to previous version..." + echo "πŸ”„ Rolling back..." if [ -d "/root/ttbackend-backup" ]; then - echo "πŸ“¦ Restoring backend from backup..." rsync -a --delete /root/ttbackend-backup/ /root/ttbackend/ cd /root/ttbackend - echo "▢️ Restarting backend..." pm2 start ecosystem.config.js --env production pm2 save echo "βœ… Rollback complete"