Remove manual workflow trigger
Some checks failed
Deploy to Production / Deploy TurboTrades (push) Has been cancelled
Some checks failed
Deploy to Production / Deploy TurboTrades (push) Has been cancelled
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user