forked from Abdulbari/sgeUpdated
Compare commits
24 Commits
cf08be1ddc
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 47f06688e0 | |||
| a0ec570147 | |||
| 7696d0f133 | |||
| e67dcea72e | |||
| 7a948f3b7e | |||
| 49ce97d394 | |||
| a7ba6fe3e4 | |||
| 7976d56552 | |||
| e3536ea6a3 | |||
| 66aeed7fda | |||
| fcc5edcbe2 | |||
| 8f41ce3d51 | |||
|
|
4ea1cfa9b4 | ||
| 68835f5919 | |||
| ee29ecd766 | |||
| f4dd4a9dce | |||
| 853230e742 | |||
| 0a4462923e | |||
| 7f56158c02 | |||
| 1174707918 | |||
| 93cad886d6 | |||
| a15f249016 | |||
| 5c1f255c3f | |||
| 453d35702c |
@@ -1,15 +1,15 @@
|
|||||||
name: sgeUpdated CI/CD
|
name: sgeUpdated CI/CD
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
pull_request:
|
||||||
|
types:
|
||||||
|
- closed # Fires when a PR is closed (either merged or manually closed)
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main # Only when PR targets main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
|
if: github.event.pull_request.merged == true # Run only if the PR was merged (not just closed)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -23,7 +23,7 @@ jobs:
|
|||||||
- name: Run deploy script on server
|
- name: Run deploy script on server
|
||||||
run: |
|
run: |
|
||||||
ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF'
|
ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF'
|
||||||
echo "✅ Connected to server. Running deploy script..."
|
echo "✅ PR merged into main — running deploy script..."
|
||||||
cd /home/ubuntu/Bgreen/sgeUpdated
|
cd /home/ubuntu/Bgreen/sgeUpdated
|
||||||
./deploy.sh
|
./deploy.sh
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
24
config.conf
Normal file
24
config.conf
Normal file
@@ -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
|
||||||
110
deploy.sh
Executable file
110
deploy.sh
Executable file
@@ -0,0 +1,110 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd /home/ubuntu/Bgreen/sgeUpdated
|
||||||
|
|
||||||
|
# -----------------------
|
||||||
|
# Harbor settings
|
||||||
|
# -----------------------
|
||||||
|
HARBOR_REGISTRY="10.150.1.166"
|
||||||
|
HARBOR_PROJECT="bgreen"
|
||||||
|
|
||||||
|
BACKEND_IMAGE_REPO="${HARBOR_REGISTRY}/${HARBOR_PROJECT}/bgreen-backend"
|
||||||
|
FRONTEND_IMAGE_REPO="${HARBOR_REGISTRY}/${HARBOR_PROJECT}/bgreen-frontend"
|
||||||
|
|
||||||
|
# Tag images with git commit (better than latest; enables rollback)
|
||||||
|
VERSION="$(git rev-parse --short HEAD)"
|
||||||
|
|
||||||
|
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 (excluding README.md)
|
||||||
|
if echo "$CHANGED_FILES" | grep "^sge-backend/" | grep -qv "README.md$"; then
|
||||||
|
BACKEND_CHANGED=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if frontend folder changed (excluding README.md)
|
||||||
|
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
|
||||||
|
|
||||||
|
echo "🐳 Building backend Docker image..."
|
||||||
|
docker build -t "${BACKEND_IMAGE_REPO}:${VERSION}" .
|
||||||
|
|
||||||
|
echo "📤 Pushing backend image to Harbor..."
|
||||||
|
docker push "${BACKEND_IMAGE_REPO}:${VERSION}"
|
||||||
|
|
||||||
|
echo "📥 Pulling backend image from Harbor (to ensure registry is source of truth)..."
|
||||||
|
docker pull "${BACKEND_IMAGE_REPO}:${VERSION}"
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
echo "🚀 Recreating backend container using Harbor image..."
|
||||||
|
VERSION="$VERSION" docker compose up -d 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 install' and 'npm run build'..."
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
else
|
||||||
|
echo "📦 only code changes. Running 'npm run build'..."
|
||||||
|
npm run build
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "🐳 Building frontend Docker image..."
|
||||||
|
docker build -t "${FRONTEND_IMAGE_REPO}:${VERSION}" .
|
||||||
|
|
||||||
|
echo "📤 Pushing frontend image to Harbor..."
|
||||||
|
docker push "${FRONTEND_IMAGE_REPO}:${VERSION}"
|
||||||
|
|
||||||
|
echo "📥 Pulling frontend image from Harbor (to ensure registry is source of truth)..."
|
||||||
|
docker pull "${FRONTEND_IMAGE_REPO}:${VERSION}"
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
echo "🚀 Recreating frontend container using Harbor image..."
|
||||||
|
VERSION="$VERSION" docker compose up -d bgreen-frontend
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "✅ No frontend changes."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ Deployment complete."
|
||||||
69
deploy.sh.save
Executable file
69
deploy.sh.save
Executable file
@@ -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."
|
||||||
|
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
bgreen-backend:
|
bgreen-backend:
|
||||||
build:
|
image: 10.150.1.166/bgreen/bgreen-backend:${VERSION}
|
||||||
context: ./sge-backend
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
env_file:
|
env_file:
|
||||||
@@ -14,9 +12,7 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
bgreen-frontend:
|
bgreen-frontend:
|
||||||
build:
|
image: 10.150.1.166/bgreen/bgreen-frontend:${VERSION}
|
||||||
context: ./sge-frontend
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
env_file:
|
env_file:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>com.sgs</groupId>
|
<groupId>com.sgs</groupId>
|
||||||
<artifactId>sgs</artifactId>
|
<artifactId>sgs</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.4-SNAPSHOT</version>
|
||||||
<name>sgs</name>
|
<name>sgs</name>
|
||||||
<description>SGS project for Spring Boot</description>
|
<description>SGS project for Spring Boot</description>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ public class SgsApplication implements CommandLineRunner {
|
|||||||
admin.setFirstName("Seda");
|
admin.setFirstName("Seda");
|
||||||
admin.setLastName("Kemikli");
|
admin.setLastName("Kemikli");
|
||||||
admin.setEmail("seda.kemikli@blc-css.com");
|
admin.setEmail("seda.kemikli@blc-css.com");
|
||||||
admin.setPhoneNumber("11111111");
|
admin.setPhoneNumber("11111511");
|
||||||
admin.setPassword(passwordEncoder.encode("admin"));
|
admin.setPassword(passwordEncoder.encode("admin"));
|
||||||
// if (organizations.size() == 1) {
|
// if (organizations.size() == 1) {
|
||||||
// admin.setOrganizations(organizations);
|
// admin.setOrganizations(organizations);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sgs-web",
|
"name": "sgs-web",
|
||||||
"version": "1.0.1",
|
"version": "1.0.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apollo/client": "^3.13.8",
|
"@apollo/client": "^3.13.8",
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ const EmissionSource = () => {
|
|||||||
?.totalElements / rowsPerPage
|
?.totalElements / rowsPerPage
|
||||||
).toFixed(1)
|
).toFixed(1)
|
||||||
);
|
);
|
||||||
|
//asdaasdasd
|
||||||
return (
|
return (
|
||||||
<ReactPaginate
|
<ReactPaginate
|
||||||
previousLabel={""}
|
previousLabel={""}
|
||||||
|
|||||||
Reference in New Issue
Block a user