forked from BLC/AyposWeb
make deploy.sh executable
All checks were successful
sgeUpdated CI/CD / deploy (push) Successful in 44s
All checks were successful
sgeUpdated CI/CD / deploy (push) Successful in 44s
This commit is contained in:
53
deploy.sh
Normal file → Executable file
53
deploy.sh
Normal file → Executable file
@@ -1,24 +1,45 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
APP_DIR="/home/ubuntu/AyposWeb"
|
||||
cd /home/ubuntu/Bgreen/AyposWeb
|
||||
|
||||
# Navigate to your app directory
|
||||
cd "$APP_DIR" || { echo "Failed to cd to $APP_DIR"; exit 1; }
|
||||
echo "Fetching latest changes from origin/main..."
|
||||
git fetch origin main
|
||||
|
||||
# Pull latest changes from Gitea
|
||||
echo "Pulling latest code..."
|
||||
git pull origin main || { echo "Git pull failed"; exit 1; }
|
||||
CHANGED_FILES=$(git diff --name-only HEAD origin/main || true)
|
||||
|
||||
# Build your app (change this to your build command)
|
||||
# For example, npm build:
|
||||
echo "Installing dependencies..."
|
||||
npm install || { echo "npm install failed"; exit 1; }
|
||||
if [ -z "$CHANGED_FILES" ]; then
|
||||
echo "No file changes detected."
|
||||
else
|
||||
echo "Changed files:"
|
||||
echo "$CHANGED_FILES"
|
||||
fi
|
||||
|
||||
echo "Building app..."
|
||||
npm run build || { echo "npm build failed"; exit 1; }
|
||||
git reset --hard origin/main
|
||||
|
||||
# Restart your app (change this to your app's restart command)
|
||||
# For example, systemctl restart myapp.service:
|
||||
systemctl reload nginx || { echo "Failed to reload nginx"; exit 1; }
|
||||
FRONTEND_CHANGED=false
|
||||
|
||||
echo "Deployment complete"
|
||||
if echo "$CHANGED_FILES" | grep -qv "README\.md$"; then
|
||||
FRONTEND_CHANGED=true
|
||||
fi
|
||||
|
||||
if [ "$FRONTEND_CHANGED" = true ]; then
|
||||
echo "Frontend changes detected."
|
||||
|
||||
if echo "$CHANGED_FILES" | grep -qE "^(package\.json|package-lock\.json)$"; then
|
||||
echo "Package files changed. Running npm install and build..."
|
||||
npm install
|
||||
npm run build
|
||||
else
|
||||
echo "Only code changes detected. Running build..."
|
||||
npm run build
|
||||
fi
|
||||
|
||||
cd ..
|
||||
echo "Rebuilding frontend container..."
|
||||
docker compose up -d --build aypos-frontend
|
||||
else
|
||||
echo "No frontend changes."
|
||||
fi
|
||||
|
||||
echo "Deployment complete."
|
||||
|
||||
Reference in New Issue
Block a user