Fix deploy.sh

Seto Elkahfi committed Aug 11, 2023 at 13:54 UTC 0b9bb69d42045858111fbd68ff89f3aac02f296c
1 file changed +20 -3
.smbpndk/deploy.sh
+20 -3
@@ -18,15 +18,32 @@ do
18
19 # start deploy tasks
20 cd $WORK_TREE
21 - nvm install $(echo .nvmrc)
21 + # Configure nvm
22 + nvm install $(cat .nvmrc)
23 nvm use
24 +
25 + # Install dependencies and build the app
26 npm install
27 npm run build
28
29 + # Check if SETOELKAHFI_COM_PORT defined in the environment variable.
30 + # If not, cancel the deployment.
31 + if [ -z ${SETOELKAHFI_COM_PORT+x} ]; then
32 + echo "❌ Deployment failed. SETOELKAHFI_COM_PORT is not defined."
33 + exit 1
34 + fi
35 +
36 + # Check if SETOELKAHFI_COM_PORT is a number.
37 + # If not, cancel the deployment.
38 + if ! [[ "$SETOELKAHFI_COM_PORT" =~ ^[0-9]+$ ]]; then
39 + echo "❌ Deployment failed. SETOELKAHFI_COM_PORT is not a number."
40 + exit 1
41 + fi
42 +
43 + # Kill existing SETOELKAHFI_COM_PORT process and start the server
44 echo "🚀 Killing existing setoelkahfi.com process..."
27 - kill $(lsof -t -i:3002)
45 + kill $(lsof -t -i:$SETOELKAHFI_COM_PORT)
46 echo "🚀 Starting server..."
29 -
47 npm run server:start > /dev/null 2>&1 &
48
49 echo "✅ Deployment complete."