From 4ea1cfa9b4e3e11af4f4175162da1cdea8424a98 Mon Sep 17 00:00:00 2001 From: abdelbari <220201877@ostimteknik.edu.tr@blc-css.com> Date: Thu, 30 Oct 2025 17:08:40 +0000 Subject: [PATCH] Test branch --- config.conf | 24 ++++++++++++++++ deploy.sh | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ deploy.sh.save | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 config.conf create mode 100755 deploy.sh create mode 100755 deploy.sh.save diff --git a/config.conf b/config.conf new file mode 100644 index 0000000..db0d3c5 --- /dev/null +++ b/config.conf @@ -0,0 +1,24 @@ +# SGE Application Configuration +# This file contains configuration for both backend and frontend + +# Database Configuration +SPRING_DATASOURCE_URL=jdbc:postgresql://bgreen-database:5432/sge +SPRING_DATASOURCE_USERNAME=sge +SPRING_DATASOURCE_PASSWORD=147 + +# Server Configuration +SERVER_PORT=8080 + +# Mail Configuration +MAIL_HOSTNAME=mail.spacemail.com +MAIL_SMTP_PORT=465 +MAIL_ADDRESS=info@blc-css.com +MAIL_PASSWORD=123456Bb@ + +# React Application Configuration +# API Configuration +API_PROTOCOL=http +API_HOST=bgreen-backend + +# Application URLs +APP_SURVEY_BASE_URL=https://bgreen.blc-css.com diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..6558dd9 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,74 @@ +#!/bin/bash +set -euo pipefail + +cd /home/ubuntu/Bgreen/sgeUpdated + +echo "📦 Fetching latest changes from origin/main..." +git fetch myfork main + +# Detect which files changed between local HEAD and the latest remote version +CHANGED_FILES=$(git diff --name-only HEAD myfork/main || true) + +if [ -z "$CHANGED_FILES" ]; then + echo "✅ No file changes detected between HEAD and origin/main." +else + echo "🪶 Changed files:" + echo "$CHANGED_FILES" +fi + +# Update to the latest version +git reset --hard myfork/main + +BACKEND_CHANGED=false +FRONTEND_CHANGED=false + +# Check if backend folder changed +if echo "$CHANGED_FILES" | grep "^sge-backend/" | grep -qv "README.md$"; then + BACKEND_CHANGED=true +fi + +# Check if frontend folder changed +if echo "$CHANGED_FILES" | grep "^sge-frontend/" | grep -qv "README.md$"; then + FRONTEND_CHANGED=true +fi + +# ----------------------- +# Backend section +# ----------------------- +if [ "$BACKEND_CHANGED" = true ]; then + echo "⚡ Backend changes detected." + cd sge-backend + echo "Running Maven build..." + /opt/apache-maven-3.9.11/bin/mvn clean install -DskipTests + cd ../.. + echo "Rebuilding 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 sge-frontend + + # Check if package.json or package-lock.json changed + if echo "$CHANGED_FILES" | grep -qE "^sge-frontend/(package\.json|package-lock\.json)$"; then + echo "📦 package.json changed. Running 'npm instal' and 'npm run build'..." + npm install + npm run build + else + echo "📦 only code changes. Running 'npm run build'..." + npm run build + fi + + cd ../.. + echo "Rebuilding frontend Docker container..." + docker compose up -d --build bgreen-frontend +else + echo "✅ No frontend changes." +fi + +echo "✅ Deployment complete." diff --git a/deploy.sh.save b/deploy.sh.save new file mode 100755 index 0000000..28bd5b7 --- /dev/null +++ b/deploy.sh.save @@ -0,0 +1,69 @@ +#!/bin/bash +set -euo pipefail + +export GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_id_rsa -o StrictHostKeyC + +cd /home/ubuntu/Bgreen/sgeUpdated + +echo "📦 Fetching latest changes from origin/main..." +git fetch origin main + +# Detect which files changed between local HEAD and the latest remote version +CHANGED_FILES=$(git diff --name-only HEAD origin/main || true) + +if [ -z "$CHANGED_FILES" ]; then + echo "✅ No file changes detected between HEAD and origin/main." +else + echo "🪶 Changed files:" + echo "$CHANGED_FILES" +fi + +# Update to the latest version +git reset --hard origin/main + +BACKEND_CHANGED=false +FRONTEND_CHANGED=false + +# Check if backend folder changed +if echo "$CHANGED_FILES" | grep -q "^sge-backend/"; then + BACKEND_CHANGED=true +fi + +# Check if frontend folder changed +if echo "$CHANGED_FILES" | grep -q "^sge-frontend/"; then + FRONTEND_CHANGED=true +fi + +# ----------------------- +# Backend section +# ----------------------- +if [ "$BACKEND_CHANGED" = true ]; then + echo "⚡ Backend changes detected." + cd sge-backend + echo "Running Maven build..." + /opt/apache-maven-3.9.11/bin/mvn clean install -DskipTests + cd .. + echo "Rebuilding 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 sge-frontend + echo "Running npm build..." + npm install + npm run build + cd .. + echo "Rebuilding frontend Docker container..." + docker compose up -d --build bgreen-frontend +else + echo "✅ No frontend changes." +fi + +echo "✅ Deployment complete." +