Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,45 @@ jobs:
key: ${{ secrets.SSH_PRIVATE_KEY }}

script: |
set -e # Exit immediately on any error

# Navigate to project directory
cd /var/www/postly

# Ensure clean state and pull latest changes (handles divergent branches)
git fetch --all
git reset --hard origin/main

# Rebuild and start services
docker compose -f docker-compose.prod.yml up -d --build
# Rebuild and start all services
docker compose -f docker-compose.prod.yml build --no-cache
docker compose -f docker-compose.prod.yml up -d

# Wait for API to become healthy
echo "Waiting for API health check..."
RETRIES=10
DELAY=5
for i in $(seq 1 $RETRIES); do
if curl -sf http://localhost:3000/health > /dev/null 2>&1; then
echo "✅ API is healthy (attempt $i/$RETRIES)"
break
fi
if [ $i -eq $RETRIES ]; then
echo "❌ API health check failed after $RETRIES attempts"
echo "--- Last 50 lines of API logs ---"
docker compose -f docker-compose.prod.yml logs api --tail=50
exit 1
fi
echo "⏳ Attempt $i/$RETRIES failed, retrying in ${DELAY}s..."
sleep $DELAY
done

# Run database migrations
docker exec postly-api npm run migrate:up
# Run database migrations (if any)
docker exec postly-api npm run migrate:up || echo "No migrations to run"

# Rebuild other services if needed
docker compose -f docker-compose.prod.yml up -d --build scraper bot

# Cleanup old images
docker image prune -f

echo "🚀 Deployment complete"
4 changes: 4 additions & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,27 @@
"@postly/shared-types": "*",
"bcrypt": "^5.1.1",
"bullmq": "^5.31.3",
"compression": "^1.8.1",
"cors": "^2.8.6",
"dotenv": "^16.4.7",
"express": "^4.21.2",
"express-prom-bundle": "^8.0.0",
"express-rate-limit": "^8.2.1",
"helmet": "^8.0.0",
"ioredis": "^5.9.2",
"jsonwebtoken": "^9.0.2",
"mammoth": "^1.11.0",
"multer": "^2.0.2",
"pdf-parse": "^2.4.5",
"prom-client": "^15.1.3",
"resend": "^6.9.4",
"zod": "^3.24.1"
},
"devDependencies": {
"@postly/eslint-config": "*",
"@postly/typescript-config": "*",
"@types/bcrypt": "^5.0.2",
"@types/compression": "^1.8.1",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/jsonwebtoken": "^9.0.7",
Expand Down
Loading
Loading