forked from Abdulbari/sgeUpdated
57 lines
1.7 KiB
YAML
57 lines
1.7 KiB
YAML
# .gitea/workflows/sgeupdated.yml
|
|
name: sgeUpdated CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main # only trigger when code is merged into main
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# 1. Checkout the repo
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v3
|
|
|
|
# 2. Detect changed files
|
|
- name: Get changed files
|
|
id: changes
|
|
run: |
|
|
echo "CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)" >> $GITHUB_ENV
|
|
|
|
# 3. Connect to server via SSH and deploy
|
|
- name: Deploy over SSH
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.SERVER_HOST }}
|
|
username: ${{ secrets.SERVER_USER }}
|
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
script: |
|
|
cd /path/to/your/project
|
|
git pull origin main
|
|
|
|
# --- Backend ---
|
|
if echo "${CHANGED_FILES}" | grep -q "sgeUpdated-backend"; then
|
|
echo "Backend changes detected..."
|
|
cd sgeUpdated-backend
|
|
mvn clean install
|
|
cd ..
|
|
docker compose build --no-cache backend
|
|
docker compose up -d --force-recreate backend
|
|
fi
|
|
|
|
# --- Frontend ---
|
|
if echo "${CHANGED_FILES}" | grep -q "sgeUpdated-frontend"; then
|
|
echo "Frontend changes detected..."
|
|
cd sgeUpdated-frontend
|
|
if echo "${CHANGED_FILES}" | grep -q "sgeUpdated-frontend/package.json"; then
|
|
echo "package.json changed → installing dependencies"
|
|
npm install
|
|
fi
|
|
npm run build
|
|
cd ..
|
|
docker compose build --no-cache frontend
|
|
docker compose up -d --force-recreate frontend
|
|
fi
|