Skip to content

Commit

Permalink
Add better error handline
Browse files Browse the repository at this point in the history
  • Loading branch information
Isengo1989 committed Dec 6, 2023
1 parent 5e655b1 commit dd68652
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions .github/scripts/watch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Set the path to the snippets folder
WATCHER_PATH=$1
ERROR_FOUND=0

# Set the Slack webhook
SLACK_WEBHOOK='https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
Expand All @@ -12,17 +13,26 @@ file_contains(){

# Check if $WATCHER_CONTAINS contains the string "null" and is therefore empty or not set
if [[ $WATCHER_CONTAINS == "null" ]]; then
exit 0
ERROR_FOUND=1
return 1
fi
# Check if $WATCHER_CONTAINS contains the string $WATCHER_CONTAINS and if not call the Slack webhook
if [[ $FILE_CONTENT == *"$WATCHER_CONTAINS"* ]]; then
echo "String found - nice!"
else
echo "String not found - not nice! Please check $WATCHER_URL"
exit 1
ERROR_FOUND=1
#curl -X POST -H 'Content-type: application/json' --data '{"text":"String not found - not nice!"}' $SLACK_WEBHOOK
fi
}
}

error_found() {
if [ "$ERROR_FOUND" -eq 1 ]
then
echo "Error found, exiting..."
exit 1
fi
}

# Find all files in the snippets folder
find $WATCHER_PATH -type f -print0 | while IFS= read -r -d '' file; do
Expand Down Expand Up @@ -51,6 +61,7 @@ find $WATCHER_PATH -type f -print0 | while IFS= read -r -d '' file; do
echo "Strings are not equal."
file_contains
fi


done

error_found

0 comments on commit dd68652

Please sign in to comment.