forked from Abdulbari/sgeUpdated
43 lines
1.2 KiB
YAML
43 lines
1.2 KiB
YAML
# .gitea/workflows/sgeupdated.yml
|
|
name: sgeUpdated CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main # trigger only when code is merged into main
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v3
|
|
|
|
- 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_stop: true
|
|
script: |
|
|
cd /home/ubuntu/sgeUpdated
|
|
git pull origin main
|
|
|
|
echo "Detecting changes..."
|
|
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
|
|
|
|
# --- Backend ---
|
|
if echo "$CHANGED_FILES" | grep -q "sge-backend"; then
|
|
echo "⚙️ Backend changes detected..."
|
|
docker compose build --no-cache backend
|
|
docker compose up -d --force-recreate backend
|
|
fi
|
|
|
|
# --- Frontend ---
|
|
if echo "$CHANGED_FILES" | grep -q "sge-frontend"; then
|
|
echo "⚙️ Frontend changes detected..."
|
|
docker compose build --no-cache frontend
|
|
docker compose up -d --force-recreate frontend
|
|
fi
|