musfi_prod / deploy.sh
abubasith86
CHG
617d6a7
raw
history blame
943 Bytes
#!/bin/bash
# Set new writable directory
APP_DIR="/home/node/app"
GIT_REPO="https://github.com/abubasith456/Node-WLA.git"
BRANCH="main"
echo "πŸš€ Deployment started..."
# Ensure the directory exists
if [ -d "$APP_DIR" ]; then
cd "$APP_DIR"
# Check if it's a valid Git repository
if [ -d ".git" ]; then
echo "πŸ“‚ Directory exists, pulling latest changes..."
git reset --hard
git pull origin "$BRANCH"
else
echo "⚠️ Not a valid Git repository. Removing directory and re-cloning..."
rm -rf "$APP_DIR"
git clone -b "$BRANCH" "$GIT_REPO" "$APP_DIR"
fi
else
echo "πŸ“‚ Directory not found. Cloning repository..."
git clone -b "$BRANCH" "$GIT_REPO" "$APP_DIR"
fi
# Navigate to the app directory
cd "$APP_DIR"
# Install dependencies
echo "πŸ“¦ Installing dependencies..."
npm install --unsafe-perm
# Start the server
echo "πŸš€ Starting the server..."
npm start