diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index ee6b611..fee7094 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -25,9 +25,13 @@ jobs: - name: Checkout run: | if [ -d $WORKDIR ]; then - cd $WORKDIR && git fetch origin && git reset --hard origin/main + cd $WORKDIR + # Save previous HEAD before reset — used by backward-compat for change detection + git rev-parse HEAD > /tmp/prev-head 2>/dev/null || true + git fetch origin && git reset --hard origin/main else git clone http://10.2.0.7:3000/wangdl/api-server.git $WORKDIR + git rev-parse HEAD > /tmp/prev-head 2>/dev/null || true fi - name: Install dependencies @@ -126,9 +130,19 @@ jobs: echo "run_compat=true" > /tmp/compat-decision exit 0 fi - # Diff against origin/main to catch all changes in this push - git fetch origin main 2>/dev/null || true - CHANGED=$(git diff --name-only origin/main...HEAD 2>/dev/null || git diff --name-only HEAD~1..HEAD 2>/dev/null || echo "") + # Diff HEAD against previous HEAD saved by build-and-unit checkout step. + # This catches exactly what changed in this push. + PREV=$(cat /tmp/prev-head 2>/dev/null || echo "") + if [ -n "$PREV" ] && [ "$PREV" != "$(git rev-parse HEAD)" ]; then + CHANGED=$(git diff --name-only $PREV..HEAD 2>/dev/null || echo "") + else + # Fallback: check last 3 commits + CHANGED="" + for n in 1 2 3; do + CHANGED="$CHANGED $(git diff --name-only HEAD~$n..HEAD 2>/dev/null || echo "")" + done + fi + echo "Previous HEAD: ${PREV:-none}" echo "Changed files: $CHANGED" if echo "$CHANGED" | grep -qE "prisma/schema.prisma|prisma/migrations/|src/modules/ai-analysis/|src/workers/ai-analysis.worker.ts|src/infrastructure/queue/|src/infrastructure/outbox/|src/modules/ai-runtime/ai-job"; then echo "DB-related changes detected — running backward compatibility"