Spaces:
Sleeping
Sleeping
# 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 | |