Files
AyposWeb/deploy.sh
server 1e1d6bcdee
All checks were successful
sgeUpdated CI/CD / deploy (push) Successful in 44s
make deploy.sh executable
2025-10-29 13:50:58 +00:00

46 lines
976 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
cd /home/ubuntu/Bgreen/AyposWeb
echo "Fetching latest changes from origin/main..."
git fetch origin main
CHANGED_FILES=$(git diff --name-only HEAD origin/main || true)
if [ -z "$CHANGED_FILES" ]; then
echo "No file changes detected."
else
echo "Changed files:"
echo "$CHANGED_FILES"
fi
git reset --hard origin/main
FRONTEND_CHANGED=false
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."