make deploy.sh executable
All checks were successful
sgeUpdated CI/CD / deploy (push) Successful in 44s

This commit is contained in:
2025-10-29 13:50:58 +00:00
parent aa4b2b3150
commit 1e1d6bcdee

53
deploy.sh Normal file → Executable file
View File

@@ -1,24 +1,45 @@
#!/bin/bash #!/bin/bash
set -euo pipefail
APP_DIR="/home/ubuntu/AyposWeb" cd /home/ubuntu/Bgreen/AyposWeb
# Navigate to your app directory echo "Fetching latest changes from origin/main..."
cd "$APP_DIR" || { echo "Failed to cd to $APP_DIR"; exit 1; } git fetch origin main
# Pull latest changes from Gitea CHANGED_FILES=$(git diff --name-only HEAD origin/main || true)
echo "Pulling latest code..."
git pull origin main || { echo "Git pull failed"; exit 1; }
# Build your app (change this to your build command) if [ -z "$CHANGED_FILES" ]; then
# For example, npm build: echo "No file changes detected."
echo "Installing dependencies..." else
npm install || { echo "npm install failed"; exit 1; } echo "Changed files:"
echo "$CHANGED_FILES"
fi
echo "Building app..." git reset --hard origin/main
npm run build || { echo "npm build failed"; exit 1; }
# Restart your app (change this to your app's restart command) FRONTEND_CHANGED=false
# For example, systemctl restart myapp.service:
systemctl reload nginx || { echo "Failed to reload nginx"; exit 1; }
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."