diff --git a/.github/scripts/watch.sh b/.github/scripts/watch.sh index fb1dc81759..11eeed1402 100755 --- a/.github/scripts/watch.sh +++ b/.github/scripts/watch.sh @@ -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' @@ -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 @@ -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