-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·54 lines (41 loc) · 1.53 KB
/
deploy.sh
File metadata and controls
executable file
·54 lines (41 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
echo "🔍 Checking changed files..."
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
IGNORED_PATTERNS='(\.md$|^docs/|\.gitignore$|\.dockerignore$|^\.vscode/|^LICENSE$|^swagger\.json$)'
if echo "$CHANGED_FILES" | grep -qE "$IGNORED_PATTERNS"; then
echo "📝 Docs-only or ignored changes detected → syncing without build"
git pull origin main
exit 0
else
echo "💡 Code-related changes detected → running full deploy process"
fi
echo "🔄 Pulling latest code..."
git pull origin main
echo "📦 Installing dependencies..."
npm ci
echo "🔨 Applying database migrations..."
npx prisma migrate deploy --schema=src/database/prisma/schema.prisma
echo "⚙️ Generating Prisma Client..."
npx prisma generate --schema=src/database/prisma/schema.prisma
echo "🏗 Building the app..."
npm run build
echo "🚀 Restarting apps with PM2..."
if pm2 describe taskora-api > /dev/null 2>&1; then
echo "📍 Restarting taskora-api..."
pm2 restart taskora-api
else
echo "🆕 Starting taskora-api from ecosystem config..."
pm2 start ecosystem.config.js --only taskora-api
fi
if pm2 describe taskora-email-worker > /dev/null 2>&1; then
echo "📍 Restarting taskora-email-worker..."
pm2 restart taskora-email-worker
else
echo "🆕 Starting taskora-email-worker from ecosystem config..."
pm2 start ecosystem.config.js --only taskora-email-worker
fi
echo "💾 Saving PM2 process list..."
pm2 save
echo "📊 Checking process status..."
pm2 describe taskora-api
echo "✅ Deployment completed successfully!"