Skip to content

Commit

Permalink
Update link checker script to produce more readable output
Browse files Browse the repository at this point in the history
  • Loading branch information
fmauch authored and VinDp committed Jun 17, 2024
1 parent 4fc7bdb commit 419d7e8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .github/helpers/check_urls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ urls=$(grep -oP "(http|ftp|https):\/\/([a-zA-Z0-9_-]+(?:(?:\.[a-zA-Z0-9_-]+)+))(

fail_counter=0

FAILED_LINKS=()
for item in $urls; do
# echo $item
filename=$(echo "$item" | cut -d':' -f1)
url=$(echo "$item" | cut -d':' -f2-)
echo "Checking $url from file $filename"
echo -n "Checking $url from file $filename"
if ! curl --head --silent --fail "$url" 2>&1 > /dev/null; then
echo "Invalid link in file $filename: $url"
echo -e " \033[0;31mNOT FOUND\033[32m\n"
FAILED_LINKS+=("$url from file $filename")
((fail_counter=fail_counter+1))
else
echo "$url ok"
printf " \033[32mok\033[0m\n"
fi
done

echo "Failed files:"
printf '%s\n' "${FAILED_LINKS[@]}"
exit $fail_counter

0 comments on commit 419d7e8

Please sign in to comment.