fix(ci): save previous HEAD for reliable change detection
- build-and-unit saves git rev-parse HEAD before reset - backward-compat uses saved PREV to compute exact diff - Falls back to HEAD~3 diff if prev-head is missing Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
96b0094c5a
commit
ade2f58ac5
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user