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:30:19 +00:00
parent e51c9fdc83
commit 8669ee3366

View File

@@ -11,6 +11,24 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: 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 - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -37,6 +55,9 @@ 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
# -------------------------
# Deploy via SSH
# -------------------------
- name: Deploy via SSH (Gitea + password) - name: Deploy via SSH (Gitea + password)
uses: appleboy/ssh-action@v1.0.0 uses: appleboy/ssh-action@v1.0.0
with: with:
@@ -45,20 +66,14 @@ jobs:
password: ${{ secrets.SERVER_PASSWORD }} password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT || 22 }} port: ${{ secrets.SERVER_PORT || 22 }}
script: | script: |
echo "🚀 Starting deployment to turbotrades.dev..." echo "🚀 Starting deployment..."
# Ensure directories exist
mkdir -p /root/ttbackend /root/ttbackend/logs /var/www/html/turbotrades mkdir -p /root/ttbackend /root/ttbackend/logs /var/www/html/turbotrades
cd /root/ttbackend cd /root/ttbackend
# Stop backend if running
echo "⏸️ Stopping backend..."
pm2 stop turbotrades-backend || echo "Backend not running" pm2 stop turbotrades-backend || echo "Backend not running"
pm2 delete turbotrades-backend || true pm2 delete turbotrades-backend || true
# Backup current version
echo "💾 Creating backup..."
if [ -d "/root/ttbackend-backup" ]; then if [ -d "/root/ttbackend-backup" ]; then
rm -rf /root/ttbackend-backup-old rm -rf /root/ttbackend-backup-old
mv /root/ttbackend-backup /root/ttbackend-backup-old mv /root/ttbackend-backup /root/ttbackend-backup-old
@@ -66,55 +81,45 @@ jobs:
mkdir -p /root/ttbackend-backup mkdir -p /root/ttbackend-backup
rsync -a --delete /root/ttbackend/ /root/ttbackend-backup/ || true rsync -a --delete /root/ttbackend/ /root/ttbackend-backup/ || true
# Pull latest code via HTTPS (password auth)
if [ -d ".git" ]; then if [ -d ".git" ]; then
echo "📥 Pulling latest code..."
git fetch origin git fetch origin
git reset --hard origin/main git reset --hard origin/main
git clean -fd git clean -fd
else else
echo "📥 Cloning repository..."
cd /root cd /root
rm -rf ttbackend rm -rf ttbackend
git clone https://username:${{ secrets.SERVER_PASSWORD }}@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
# Install backend dependencies
echo "📦 Installing backend dependencies..."
npm ci --production npm ci --production
# Build frontend
echo "🎨 Building frontend..."
cd frontend cd frontend
npm ci npm ci
npm run build npm run build
# Deploy frontend
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/
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
# Start backend
cd /root/ttbackend cd /root/ttbackend
echo "▶️ Starting backend..."
pm2 start ecosystem.config.js --env production pm2 start ecosystem.config.js --env production
pm2 save pm2 save
echo "✅ Deployment complete!" echo "✅ Deployment complete!"
pm2 list pm2 list
# -------------------------
# Health Check
# -------------------------
- name: Health Check - name: Health Check
run: | run: |
echo "⏳ Waiting for services to start..."
sleep 15 sleep 15
echo "🏥 Checking backend..."
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..."
curl -f https://turbotrades.dev || echo "⚠️ Frontend check failed" curl -f https://turbotrades.dev || echo "⚠️ Frontend check failed"
# -------------------------
# Notifications
# -------------------------
- name: Notify Success - name: Notify Success
if: success() if: success()
run: | run: |
@@ -138,12 +143,10 @@ jobs:
password: ${{ secrets.SERVER_PASSWORD }} password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT || 22 }} port: ${{ secrets.SERVER_PORT || 22 }}
script: | script: |
echo "🔄 Rolling back to previous version..." echo "🔄 Rolling back..."
if [ -d "/root/ttbackend-backup" ]; then if [ -d "/root/ttbackend-backup" ]; then
echo "📦 Restoring backend from backup..."
rsync -a --delete /root/ttbackend-backup/ /root/ttbackend/ rsync -a --delete /root/ttbackend-backup/ /root/ttbackend/
cd /root/ttbackend cd /root/ttbackend
echo "▶️ Restarting backend..."
pm2 start ecosystem.config.js --env production pm2 start ecosystem.config.js --env production
pm2 save pm2 save
echo "✅ Rollback complete" echo "✅ Rollback complete"