Add deploy.sh
Seto Elkahfi committed
Aug 11, 2023 at 13:21 UTC
fb8f3a3b8406c48019cffc3e32f4644b414c6b18
1 file changed
+36
.smbpndk/deploy.sh
new
+36
@@ -0,0 +1,36 @@
1
+#!/bin/bash
2
+
3
+# The bare git directory
4
+GIT_DIR=/home/deploy/setoelkahfi.com
5
+# The app directory
6
+WORK_TREE=/home/deploy/apps/ssr/setoelkahfi.com
7
+
8
+# Put environment variabels here
9
+. ~/.profile
10
+
11
+while read oldrev newrev ref
12
+do
13
+ if [[ $ref =~ .*/main$ ]];
14
+ then
15
+ echo "🚀 Main ref received. Deploying main branch to production..."
16
+ mkdir -p $WORK_TREE
17
+ git --work-tree=$WORK_TREE --git-dir=$GIT_DIR checkout -f main
18
+
19
+ # start deploy tasks
20
+ cd $WORK_TREE
21
+ nvm install $(echo .nvmrc)
22
+ nvm use
23
+ npm install
24
+ npm run build
25
+
26
+ echo "🚀 Killing existing setoelkahfi.com process..."
27
+ kill $(lsof -t -i:3002)
28
+ echo "🚀 Starting server..."
29
+
30
+ npm run server:start > /dev/null 2>&1 &
31
+
32
+ echo "✅ Deployment complete."
33
+ else
34
+ echo "Ref $ref successfully received. Doing nothing: only the main branch may be deployed on this server."
35
+ fi
36
+done