Skip to content

Commit

Permalink
test git separately -trap
Browse files Browse the repository at this point in the history
  • Loading branch information
anadelarosa3 committed Sep 10, 2024
1 parent aebebb5 commit 4c8e7e8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ci/files_changed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@ trap 'echo "An unexpected error occurred during file change check."; echo "check
# base_ref="origin/$GITHUB_BASE_REF"
#fi

# Check if the base ref exists before running the git diff
if git rev-parse --abbrev-ref HEAD | grep -q ^main$ || git fetch origin "$GITHUB_BASE_REF" && git diff --name-only "origin/$GITHUB_BASE_REF" | grep -E "$1" ; then
if git rev-parse --abbrev-ref HEAD | grep -q ^main$ ; then
echo "Relevant file changes detected!"
echo "check_result=0" >> "$GITHUB_OUTPUT"
exit 0 # Relevant changes detected
exit 0
fi

# Run git diff and store output
diff_output=$(git diff --name-only "origin/$GITHUB_BASE_REF") || exit 1 # Ensure git diff failures are caught

# Check for relevant file changes
if echo "$diff_output" | grep -E "$1" ; then
echo "Relevant file changes detected!"
echo "check_result=0" >> "$GITHUB_OUTPUT"
exit 0
else
echo "No relevant changes found."
echo "check_result=2" >> "$GITHUB_OUTPUT"
Expand Down

0 comments on commit 4c8e7e8

Please sign in to comment.