Skip to content

Commit 8b13d02

Browse files
authored
fix(ci): Adjust detect_changed_files script to run properly against default branch
1 parent 6a8a68a commit 8b13d02

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

.github/scripts/detect_changed_files.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ set -e
55
# Script to check if files from specific pattern groups have changed in a PR
66
# Groups: backend, postgres, ui
77

8-
changed_files=$(git diff --name-only "origin/$GITHUB_BASE_REF...HEAD")
8+
if [[ "$GITHUB_REF" == "refs/heads/main" ]]; then
9+
echo "Running on main branch, comparing with previous commit"
10+
changed_files=$(git diff --name-only HEAD^ HEAD)
11+
else
12+
echo "Running on non-default branch, comparing with $GITHUB_BASE_REF branch"
13+
changed_files=$(git diff --name-only origin/$GITHUB_BASE_REF...HEAD)
14+
fi
15+
916

1017
if [ -z "$changed_files" ]; then
1118
echo "No files changed in this PR compared to $GITHUB_BASE_REF branch."

0 commit comments

Comments
 (0)