Update sgeupdated pipeline v21
Some checks failed
sgeUpdated CI/CD / deploy (push) Failing after 20s

new condition to be added
This commit is contained in:
2025-10-22 14:29:27 +03:00
parent 02bd570573
commit a11f9614ed

View File

@@ -4,8 +4,8 @@ name: sgeUpdated CI/CD
on:
push:
branches:
- main # trigger only when code is merged into main
workflow_dispatch: # allow manual trigger
- main
workflow_dispatch:
concurrency:
group: sgeupdated-deploy-${{ github.ref }}
@@ -30,20 +30,59 @@ jobs:
cd /home/ubuntu/Bgreen/sgeUpdated
git fetch origin main
# Detect which files changed in the last commit
CHANGED_FILES=$(git diff --name-only HEAD HEAD~1)
echo "🪶 Changed files:"
echo "$CHANGED_FILES"
git reset --hard origin/main
echo "⚡ Rebuilding Backend..."
cd sgeUpdated/sge-backend
/opt/apache-maven-3.9.11/bin/mvn clean install -DskipTests
cd ../..
docker compose up -d --build bgreen-backend
BACKEND_CHANGED=false
FRONTEND_CHANGED=false
echo "⚡ Rebuilding Frontend..."
# Check if backend folder changed
if echo "$CHANGED_FILES" | grep -q "^sgeUpdated/sge-backend/"; then
BACKEND_CHANGED=true
fi
# Check if frontend folder changed
if echo "$CHANGED_FILES" | grep -q "^sgeUpdated/sge-frontend/"; then
FRONTEND_CHANGED=true
fi
# Backend section
if [ "$BACKEND_CHANGED" = true ]; then
echo "⚡ Backend changes detected."
cd sgeUpdated/sge-backend
echo "Would run Maven build here..."
# /opt/apache-maven-3.9.11/bin/mvn clean install -DskipTests
cd ../..
echo "Would rebuild backend Docker container..."
# docker compose up -d --build bgreen-backend
else
echo "✅ No backend changes."
fi
# Frontend section
if [ "$FRONTEND_CHANGED" = true ]; then
echo "⚡ Frontend changes detected."
cd sgeUpdated/sge-frontend
echo "Would run npm build here..."
# npm install
# npm run build
cd ../..
docker compose up -d --build bgreen-frontend
echo "Would rebuild frontend Docker container..."
# docker compose up -d --build bgreen-frontend
else
echo "✅ No frontend changes."
fi
echo "✅ Deployment complete. Current containers:"
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
# If no changes at all, just restart containers (commented for now)
if [ "$BACKEND_CHANGED" = false ] && [ "$FRONTEND_CHANGED" = false ]; then
echo "♻️ No source changes detected. (Would restart containers here...)"
# docker compose up -d
fi
echo "✅ Check complete. (No rebuild or restart performed.)"