Skip to content

Commit

Permalink
Test script
Browse files Browse the repository at this point in the history
  • Loading branch information
Isengo1989 committed Dec 6, 2023
1 parent 464336f commit 94f8a95
Showing 1 changed file with 21 additions and 38 deletions.
59 changes: 21 additions & 38 deletions .github/scripts/watch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,6 @@
WATCHER_PATH=$1 $2
ERROR_FOUND=0

output() {
echo "$1"
}

file_contains(){
# Get the content of the URL
FILE_CONTENT=$(curl -sl $WATCHER_URL)

# Check if $WATCHER_CONTAINS contains the string "null" and is therefore empty or not set
if [[ $WATCHER_CONTAINS == "null" ]]; then
output "No contain set"
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
output "String found!"
else
output echo "String not found! Please check $WATCHER_URL"
return 1
fi
}

error_found() {
echo "Error found: $1"
if [ "$1" -eq 0 ]
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
# Check if the file contains the string "WATCHER_URL" and is therefore a watcher file
Expand All @@ -59,14 +28,28 @@ find $WATCHER_PATH -type f -print0 | while IFS= read -r -d '' file; do
echo "Both strings are equal."
else
echo "Strings are not equal."
if [ $ERROR_FOUND -eq 1 ]
then
file_contains
else
ERROR_FOUND="$(file_contains)"
fi

FILE_CONTENT=$(curl -sl $WATCHER_URL)

# Check if $WATCHER_CONTAINS contains the string "null" and is therefore empty or not set
if [[ $WATCHER_CONTAINS == "null" ]]; then
echo "No contain set"
ERROR_FOUND=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!"
else
echo "String not found! Please check $WATCHER_URL"
ERROR_FOUND=1
fi

fi

done

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

0 comments on commit 94f8a95

Please sign in to comment.