-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added New job in workflow check README.md file
- Loading branch information
Showing
4 changed files
with
112 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
if [[ "$#" -gt 2 ]] | ||
then | ||
echo -e "[!] - ERROR : Extra Argument Specified\nUsage : $0 [path_to_challs_directory] [path_to_readme_file]" >&2 | ||
exit 1 | ||
elif [[ "$#" -lt 2 ]] | ||
then | ||
echo -e "[!] - ERROR : Missing Argument\nUsage : $0 [path_to_challs_directory] [path_to_readme_file]" >&2 | ||
exit 1 | ||
else | ||
LINES_IN_TABLE=$(grep -Pc "^\|" "$2") | ||
COUNTER=0 | ||
|
||
mapfile -t CHALLS_UNDER_DIR < <(echo $(ls "$1" | sort)) | ||
mapfile -t CHALLS_IN_TABLE < <(echo $(grep -P "^\|" "$2" | tail -n $(($LINES_IN_TABLE - 2)) | cut -d '|' -f 2 | sort )) | ||
|
||
|
||
for dir_chall in "${CHALLS_UNDER_DIR[@]}" | ||
do | ||
for tab_chall in "${CHALLS_IN_TABLE[@]}" | ||
do | ||
if [[ "$dir_chall" = "$tab_chall" ]] | ||
then | ||
COUNTER=$(( $COUNTER + 1 )) | ||
fi | ||
done | ||
done | ||
|
||
if [[ $COUNTER -eq $(($(ls -l "$1" | wc -l ) - 1)) ]] | ||
then | ||
echo "[*] - SUCCESS : Challs in README.md and Directory are the same" | ||
exit 0 | ||
else | ||
echo "[!] - ERROR : Checking Failed" >&2 | ||
exit 1 | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
if [[ "$#" -gt 2 ]] | ||
then | ||
echo -e "[!] - ERROR : Extra Argument Specified\nUsage : $0 [path_to_challs_directory] [path_to_readme_file]" >&2 | ||
exit 1 | ||
elif [[ "$#" -lt 2 ]] | ||
then | ||
echo -e "[!] - ERROR : Missing Argument\nUsage : $0 [path_to_challs_directory] [path_to_readme_file]" >&2 | ||
exit 1 | ||
else | ||
LINES_IN_TABLE=$(grep -Pc "^\|" "$2") | ||
COUNTER=0 | ||
|
||
mapfile -t CHALLS_UNDER_DIR < <(echo $(ls "$1" | sort)) | ||
mapfile -t CHALLS_IN_TABLE < <(echo $(grep -P "^\|" "$2" | tail -n $(($LINES_IN_TABLE - 2)) | cut -d '|' -f 2 | sort )) | ||
|
||
|
||
for dir_chall in "${CHALLS_UNDER_DIR[@]}" | ||
do | ||
for tab_chall in "${CHALLS_IN_TABLE[@]}" | ||
do | ||
if [[ "$dir_chall" = "$tab_chall" ]] | ||
then | ||
COUNTER=$(( $COUNTER + 1 )) | ||
fi | ||
done | ||
done | ||
|
||
if [[ $COUNTER -eq $(($(ls -l "$1" | wc -l ) - 1)) ]] | ||
then | ||
echo "[*] - SUCCESS : Challs in README.md and Directory are the same" | ||
exit 0 | ||
else | ||
echo "[!] - ERROR : Checking Failed" >&2 | ||
exit 1 | ||
fi | ||
fi |