diff --git a/update-gitops-status.sh b/update-gitops-status.sh index a7a8ffb..2ba469f 100644 --- a/update-gitops-status.sh +++ b/update-gitops-status.sh @@ -74,12 +74,12 @@ if [ "$MODE" = "post-deploy" ]; then if command -v git >/dev/null 2>&1 && [ -d .git ]; then # Try multiple methods to detect changed files (Woodpecker might do shallow clone) - # Method 1: Use git show to see files in HEAD commit - CHANGED_FILE_PATHS=$(git show --name-only --pretty="" HEAD -- files/ 2>/dev/null || echo "") + # Method 1: Use git diff to see actual file changes (most accurate) + CHANGED_FILE_PATHS=$(git diff --name-only HEAD~1 HEAD -- files/ 2>/dev/null || echo "") - # Method 2: If method 1 fails, try diff with parent (if it exists) + # Method 2: If method 1 fails (no parent commit), use git show if [ -z "$CHANGED_FILE_PATHS" ]; then - CHANGED_FILE_PATHS=$(git diff --name-only HEAD~1 HEAD -- files/ 2>/dev/null || echo "") + CHANGED_FILE_PATHS=$(git show --name-only --pretty="" HEAD -- files/ 2>/dev/null || echo "") fi # Method 3: If still nothing, check Woodpecker CI environment variables