forked from BLC/sgeUpdated
Update .gitea/workflows/sgeupdated.yml
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
# .gitea/workflows/sgeupdated.yml
|
|
||||||
name: sgeUpdated CI/CD
|
name: sgeUpdated CI/CD
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main # trigger only when code is merged into main
|
- main # Trigger when code is pushed/merged into main
|
||||||
workflow_dispatch: # allow manual trigger
|
workflow_dispatch: # Allow manual trigger if needed
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: sgeupdated-deploy-${{ github.ref }}
|
group: sgeupdated-deploy-${{ github.ref }}
|
||||||
@@ -14,11 +13,34 @@ concurrency:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
|
||||||
- name: Checkout repo
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Deploy over SSH
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 2 # Needed to compare the last two commits
|
||||||
|
|
||||||
|
- name: Detect changed files
|
||||||
|
id: detect
|
||||||
|
run: |
|
||||||
|
echo "🔍 Checking which files changed..."
|
||||||
|
FRONTEND_CHANGED=false
|
||||||
|
BACKEND_CHANGED=false
|
||||||
|
|
||||||
|
# Get list of changed files between the latest two commits
|
||||||
|
CHANGED=$(git diff --name-only HEAD^ HEAD || true)
|
||||||
|
|
||||||
|
echo "$CHANGED" | grep -q '^sgeUpdated/sge-frontend/' && FRONTEND_CHANGED=true || true
|
||||||
|
echo "$CHANGED" | grep -q '^sgeUpdated/sge-backend/' && BACKEND_CHANGED=true || true
|
||||||
|
|
||||||
|
echo "frontend=$FRONTEND_CHANGED" >> $GITHUB_OUTPUT
|
||||||
|
echo "backend=$BACKEND_CHANGED" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
echo "✅ Frontend changed: $FRONTEND_CHANGED"
|
||||||
|
echo "✅ Backend changed: $BACKEND_CHANGED"
|
||||||
|
|
||||||
|
- name: Deploy Backend
|
||||||
|
if: ${{ steps.detect.outputs.backend == 'true' }}
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
with:
|
with:
|
||||||
host: ${{ secrets.SERVER_HOST }}
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
@@ -28,22 +50,43 @@ jobs:
|
|||||||
script: |
|
script: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "🚀 Starting backend deployment..."
|
||||||
cd /home/ubuntu/Bgreen/sgeUpdated
|
cd /home/ubuntu/Bgreen/sgeUpdated
|
||||||
git fetch origin main
|
git fetch origin main
|
||||||
git reset --hard origin/main
|
git reset --hard origin/main
|
||||||
|
|
||||||
echo "⚡ Rebuilding Backend..."
|
echo "⚙️ Rebuilding Backend..."
|
||||||
cd sgeUpdated/sge-backend
|
cd sgeUpdated/sge-backend
|
||||||
/opt/apache-maven-3.9.11/bin/mvn clean install -DskipTests
|
/opt/apache-maven-3.9.11/bin/mvn clean install -DskipTests
|
||||||
cd ../..
|
cd ../..
|
||||||
docker compose up -d --build bgreen-backend
|
docker compose up -d --build bgreen-backend
|
||||||
|
|
||||||
echo "⚡ Rebuilding Frontend..."
|
echo "✅ Backend deployment complete!"
|
||||||
|
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
|
||||||
|
|
||||||
|
- name: Deploy Frontend
|
||||||
|
if: ${{ steps.detect.outputs.frontend == 'true' }}
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SERVER_HOST }}
|
||||||
|
username: ${{ secrets.SERVER_USER }}
|
||||||
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
script_stop: true
|
||||||
|
script: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "🚀 Starting frontend deployment..."
|
||||||
|
cd /home/ubuntu/Bgreen/sgeUpdated
|
||||||
|
git fetch origin main
|
||||||
|
git reset --hard origin/main
|
||||||
|
|
||||||
|
echo "⚙️ Rebuilding Frontend..."
|
||||||
cd sgeUpdated/sge-frontend
|
cd sgeUpdated/sge-frontend
|
||||||
# npm install
|
# Uncomment below if needed:
|
||||||
|
# npm ci
|
||||||
# npm run build
|
# npm run build
|
||||||
cd ../..
|
cd ../..
|
||||||
docker compose up -d --build bgreen-frontend
|
docker compose up -d --build bgreen-frontend
|
||||||
|
|
||||||
echo "✅ Deployment complete. Current containers:"
|
echo "✅ Frontend deployment complete!"
|
||||||
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
|
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
|
||||||
Reference in New Issue
Block a user