Files
sgeUpdated/.gitea/workflows/sgeupdated.yml

62 lines
2.4 KiB
YAML

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# Fetch all history so we can diff the 'before' and 'after' SHAs
fetch-depth: 0
- name: Detect changed files
id: detect
run: |
echo "🔍 Checking which files changed..."
FRONTEND_CHANGED=false
BACKEND_CHANGED=false
# 1. Handle MANUAL RUN (workflow_dispatch)
# If triggered manually, assume we want to deploy everything.
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo " MANUAL RUN: Forcing deployment for both frontend and backend."
FRONTEND_CHANGED=true
BACKEND_CHANGED=true
# 2. Handle FIRST PUSH (before SHA is all zeros)
# If this is the first push to a new branch, deploy everything.
elif [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then
echo " NEW BRANCH/FIRST PUSH: Forcing deployment for both."
FRONTEND_CHANGED=true
BACKEND_CHANGED=true
# 3. Handle a normal PUSH event
# Reliably diff between the two SHAs of the push.
else
echo " PUSH EVENT: Diffing from ${{ github.event.before }} to ${{ github.event.after }}"
CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }})
echo "--- Changed Files ---"
echo "$CHANGED"
echo "---------------------"
echo "$CHANGED" | grep -q '^sgeUpdated/sge-frontend/' && FRONTEND_CHANGED=true || true
echo "$CHANGED" | grep -q '^sgeUpdated/sge-backend/' && BACKEND_CHANGED=true || true
fi
# 4. Set outputs
echo "frontend=$FRONTEND_CHANGED" >> $GITHUB_OUTPUT
echo "backend=$BACKEND_CHANGED" >> $GITHUB_OUTPUT
echo "✅ Frontend changed: $FRONTEND_CHANGED"
echo "✅ Backend changed: $BACKEND_CHANGED"
# ... your Deploy Baackend and Deploy Frontend steps remain the same ...
- name: Deploy Backend
if: ${{ steps.detect.outputs.backend == 'true' }}
# ... (rest of your step) ...
- name: Deploy Frontend
if: ${{ steps.detect.outputs.frontend == 'true' }}
# ... (rest of your step) ...