Fix CI change detection: save old HEAD before fetch/reset
The diff was comparing HEAD vs origin after fetch, but before the first real push they point to the same commit — producing an empty diff and skipping all builds. Now saves HEAD before fetch so the comparison works, and falls back to rebuild-all when HEAD hasn't moved (first deploy or CI re-run on same commit).
This commit is contained in:
@@ -34,18 +34,28 @@ jobs:
|
||||
run: |
|
||||
ssh "root@$DEPLOY_HOST" "
|
||||
cd ${{ env.COOP_DIR }}
|
||||
git fetch origin ${{ github.ref_name }}
|
||||
|
||||
# Detect what changed since current HEAD
|
||||
CHANGED=\$(git diff --name-only HEAD origin/${{ github.ref_name }})
|
||||
# Save current HEAD before updating
|
||||
OLD_HEAD=\$(git rev-parse HEAD 2>/dev/null || echo none)
|
||||
|
||||
git fetch origin ${{ github.ref_name }}
|
||||
git reset --hard origin/${{ github.ref_name }}
|
||||
|
||||
NEW_HEAD=\$(git rev-parse HEAD)
|
||||
|
||||
# Detect what changed
|
||||
REBUILD_ALL=false
|
||||
if echo \"\$CHANGED\" | grep -q '^shared/'; then
|
||||
REBUILD_ALL=true
|
||||
fi
|
||||
if echo \"\$CHANGED\" | grep -q '^docker-compose.yml'; then
|
||||
if [ \"\$OLD_HEAD\" = \"none\" ] || [ \"\$OLD_HEAD\" = \"\$NEW_HEAD\" ]; then
|
||||
# First deploy or CI re-run on same commit — rebuild all
|
||||
REBUILD_ALL=true
|
||||
else
|
||||
CHANGED=\$(git diff --name-only \$OLD_HEAD \$NEW_HEAD)
|
||||
if echo \"\$CHANGED\" | grep -q '^shared/'; then
|
||||
REBUILD_ALL=true
|
||||
fi
|
||||
if echo \"\$CHANGED\" | grep -q '^docker-compose.yml'; then
|
||||
REBUILD_ALL=true
|
||||
fi
|
||||
fi
|
||||
|
||||
for app in blog market cart events federation account; do
|
||||
|
||||
Reference in New Issue
Block a user