Remove manual workflow trigger
Some checks failed
Deploy to Production / Deploy TurboTrades (push) Has been cancelled

This commit is contained in:
2026-01-11 00:26:17 +00:00
parent f160d44d23
commit 26dba315dd

View File

@@ -4,10 +4,11 @@ on:
push: push:
branches: branches:
- main - main
workflow_dispatch: # allows manual trigger if needed
jobs: jobs:
deploy: deploy:
name: Deploy to turbotrades.dev name: Deploy TurboTrades
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -37,7 +38,7 @@ jobs:
VITE_API_URL: https://api.turbotrades.dev VITE_API_URL: https://api.turbotrades.dev
VITE_WS_URL: https://ws.turbotrades.dev VITE_WS_URL: https://ws.turbotrades.dev
- name: Deploy to Production - name: Deploy via SSH (Gitea + password)
uses: appleboy/ssh-action@v1.0.0 uses: appleboy/ssh-action@v1.0.0
with: with:
host: ${{ secrets.SERVER_HOST }} host: ${{ secrets.SERVER_HOST }}
@@ -47,17 +48,15 @@ jobs:
script: | script: |
echo "🚀 Starting deployment to turbotrades.dev..." echo "🚀 Starting deployment to turbotrades.dev..."
# Create directories if they don't exist # Ensure directories exist
mkdir -p /root/ttbackend mkdir -p /root/ttbackend /root/ttbackend/logs /var/www/html/turbotrades
mkdir -p /root/ttbackend/logs
mkdir -p /var/www/html/turbotrades
# Navigate to backend directory
cd /root/ttbackend cd /root/ttbackend
# Stop the application # Stop backend if running
echo "⏸️ Stopping backend..." echo "⏸️ Stopping backend..."
pm2 stop turbotrades-backend || echo "Backend not running" pm2 stop turbotrades-backend || echo "Backend not running"
pm2 delete turbotrades-backend || true
# Backup current version # Backup current version
echo "💾 Creating backup..." echo "💾 Creating backup..."
@@ -66,9 +65,9 @@ jobs:
mv /root/ttbackend-backup /root/ttbackend-backup-old mv /root/ttbackend-backup /root/ttbackend-backup-old
fi fi
mkdir -p /root/ttbackend-backup mkdir -p /root/ttbackend-backup
cp -r /root/ttbackend/* /root/ttbackend-backup/ 2>/dev/null || true rsync -a --delete /root/ttbackend/ /root/ttbackend-backup/ || true
# Clone or pull repository # Pull latest code via HTTPS (password auth)
if [ -d ".git" ]; then if [ -d ".git" ]; then
echo "📥 Pulling latest code..." echo "📥 Pulling latest code..."
git fetch origin git fetch origin
@@ -77,8 +76,8 @@ jobs:
else else
echo "📥 Cloning repository..." echo "📥 Cloning repository..."
cd /root cd /root
rm -rf ttbackend/* rm -rf ttbackend
git clone https://git.turbotrades.dev/iDefineHD/TurboTrades.git ttbackend git clone https://username:${{ secrets.SERVER_PASSWORD }}@git.turbotrades.dev/iDefineHD/TurboTrades.git ttbackend
cd ttbackend cd ttbackend
fi fi
@@ -92,43 +91,30 @@ jobs:
npm ci npm ci
npm run build npm run build
# Deploy frontend to nginx directory # Deploy frontend
echo "🚀 Deploying frontend to /var/www/html/turbotrades..." echo "🚀 Deploying frontend..."
rm -rf /var/www/html/turbotrades/* rm -rf /var/www/html/turbotrades/*
cp -r dist/* /var/www/html/turbotrades/ cp -r dist/* /var/www/html/turbotrades/
# Set proper permissions
chown -R www-data:www-data /var/www/html/turbotrades chown -R www-data:www-data /var/www/html/turbotrades
chmod -R 755 /var/www/html/turbotrades chmod -R 755 /var/www/html/turbotrades
# Back to backend directory # Start backend
cd /root/ttbackend cd /root/ttbackend
echo "▶️ Starting backend..."
# Start backend with PM2
echo "▶️ Starting backend..."
pm2 start ecosystem.config.js --env production pm2 start ecosystem.config.js --env production
pm2 save pm2 save
# Verify deployment
echo "✅ Deployment complete!" echo "✅ Deployment complete!"
echo ""
echo "📊 PM2 Status:"
pm2 list pm2 list
echo ""
echo "🌐 Frontend: https://turbotrades.dev"
echo "🔧 Backend: https://api.turbotrades.dev"
echo "💬 WebSocket: https://ws.turbotrades.dev"
- name: Health Check - name: Health Check
run: | run: |
echo "⏳ Waiting for services to start..." echo "⏳ Waiting for services to start..."
sleep 15 sleep 15
echo "🏥 Checking backend..."
echo "🏥 Checking backend health..." curl -f https://api.turbotrades.dev/api/health || echo "⚠️ Backend health check failed"
curl -f https://api.turbotrades.dev/api/health || echo "⚠️ Backend health check failed"
echo "🏥 Checking frontend..." echo "🏥 Checking frontend..."
curl -f https://turbotrades.dev || echo "⚠️ Frontend check failed" curl -f https://turbotrades.dev || echo "⚠️ Frontend check failed"
- name: Notify Success - name: Notify Success
if: success() if: success()
@@ -142,8 +128,7 @@ jobs:
- name: Notify Failure - name: Notify Failure
if: failure() if: failure()
run: | run: |
echo "❌ Deployment failed!" echo "❌ Deployment failed! Check logs above."
echo "Check the logs above for details"
- name: Rollback on Failure - name: Rollback on Failure
if: failure() if: failure()
@@ -155,18 +140,13 @@ jobs:
port: ${{ secrets.SERVER_PORT || 22 }} port: ${{ secrets.SERVER_PORT || 22 }}
script: | script: |
echo "🔄 Rolling back to previous version..." echo "🔄 Rolling back to previous version..."
if [ -d "/root/ttbackend-backup" ]; then if [ -d "/root/ttbackend-backup" ]; then
echo "📦 Restoring backend from backup..." echo "📦 Restoring backend from backup..."
cd /root rsync -a --delete /root/ttbackend-backup/ /root/ttbackend/
rm -rf ttbackend cd /root/ttbackend
cp -r ttbackend-backup ttbackend echo "▶️ Restarting backend..."
cd ttbackend pm2 start ecosystem.config.js --env production
echo "▶️ Restarting backend..."
pm2 restart turbotrades-backend
pm2 save pm2 save
echo "✅ Rollback complete" echo "✅ Rollback complete"
else else
echo "❌ No backup found!" echo "❌ No backup found!"