mirror of
https://github.com/edoardottt/awesome-hacker-search-engines.git
synced 2024-12-11 16:44:22 -05:00
Added github action and updated check-dups.sh
This commit is contained in:
parent
8bf68a52bd
commit
5d4ad39cc9
20
.github/workflows/check-duplicates.yml
vendored
Normal file
20
.github/workflows/check-duplicates.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: Check Duplicates
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-duplicates:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check Out Code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Run Check Duplicates Script
|
||||||
|
run: |
|
||||||
|
chmod +x scripts/check-dups.sh
|
||||||
|
./scripts/check-dups.sh
|
||||||
|
working-directory: ${{ github.workspace }}
|
@ -14,15 +14,24 @@ then
|
|||||||
readme="../README.md"
|
readme="../README.md"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
links=$(cat $readme | egrep "\- \[" | wc -l)
|
# Function to extract links from a section and check for duplicates
|
||||||
|
check_section() {
|
||||||
|
section=$1
|
||||||
|
section_escaped=$(sed 's/[&/\]/\\&/g' <<< "$section")
|
||||||
|
section_content=$(awk -v section="$section" '/^### / {p=0} {if(p)print} /^### '"$section"'/ {p=1}' "$readme")
|
||||||
|
duplicate_links=$(echo "$section_content" | grep -oP '\[.*?\]\(\K[^)]+' | sort | uniq -d)
|
||||||
|
if [[ -n $duplicate_links ]]; then
|
||||||
|
echo "[ ERR ] DUPLICATE LINKS FOUND"
|
||||||
|
echo "$duplicate_links"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
uniqlinks=$(cat $readme | egrep "\- \[" | uniq | wc -l)
|
# Get all unique section headings from the README file and handle spaces and slashes
|
||||||
|
sections=$(grep '^### ' "$readme" | sed 's/^### //' | sed 's/[\/&]/\\&/g')
|
||||||
|
|
||||||
if [[ $links -eq $uniqlinks ]];
|
# Call the function for each section
|
||||||
then
|
for section in $sections; do
|
||||||
echo "[ OK! ] NO DUPLICATES FOUND."
|
check_section "$section"
|
||||||
echo "$links links in README."
|
done
|
||||||
else
|
echo "[ OK! ] NO DUPLICATES FOUND."
|
||||||
echo "[ ERR ] DUPLICATES FOUND!"
|
|
||||||
cat $readme | egrep "\- \[" | uniq -c | egrep -iv "1 - ["
|
|
||||||
fi
|
|
Loading…
Reference in New Issue
Block a user