-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·75 lines (61 loc) · 1.62 KB
/
deploy.sh
File metadata and controls
executable file
·75 lines (61 loc) · 1.62 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Ps. Script has to be in the project root directory
# Root path of the repository
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Parent directory where the apps are deployed (matching existing logic)
DEPLOY_ROOT="$(cd "$REPO_ROOT/.." && pwd)"
deploy_frontend() {
echo "🚀 Deploying Frontend..."
cd "$DEPLOY_ROOT" || { echo "Failed to enter $DEPLOY_ROOT"; exit 1; }
# Remove old build, copy fresh files
rm -rf client
cp -r "$REPO_ROOT/client" ./
cp .env.local ./client/ 2>/dev/null || echo "Warning: .env.local not found in $DEPLOY_ROOT"
cd client || exit
pnpm install
pnpm run build
# Restart PM2 process
pm2 delete cognicv-frontend 2>/dev/null || true
pnpm run deploy
pm2 save
echo "✅ Frontend deployed successfully!"
}
deploy_backend() {
echo "🚀 Deploying Backend..."
cd "$DEPLOY_ROOT" || { echo "Failed to enter $DEPLOY_ROOT"; exit 1; }
# Remove old build, copy fresh files
rm -rf server
cp -r "$REPO_ROOT/server" ./
cp .env.server ./server/.env 2>/dev/null || echo "Warning: .env.server not found in $DEPLOY_ROOT"
cd server || exit
pnpm install
pnpm run build
# Restart PM2 process
pm2 delete cognicv-backend 2>/dev/null || true
pnpm run deploy
pm2 save
echo "✅ Backend deployed successfully!"
}
# Simple selection menu
echo "What app are you updating?"
echo "1: client"
echo "2: server"
echo "3: All apps"
read -p "Enter app number: " site
case $site in
1)
deploy_frontend
;;
2)
deploy_backend
;;
3)
deploy_backend
deploy_frontend
;;
*)
echo "Invalid choice"
exit 1
;;
esac
echo "Done!"