Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dead-link-checker can't find out dead links (#596) #609

Merged
merged 5 commits into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .dlc.json → .github/dead_link_check_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
},
{
"pattern": "^https://console.cloud.tencent.com/cos/bucket"
},
{
"pattern": "^#"
seeflood marked this conversation as resolved.
Show resolved Hide resolved
}
],
"replacementPatterns": [
Expand All @@ -33,6 +36,7 @@
"fallbackRetryDelay": "1s",
"aliveStatusCodes": [
200,
401
401,
403
seeflood marked this conversation as resolved.
Show resolved Hide resolved
]
}
2 changes: 1 addition & 1 deletion .github/workflows/dead-link-checker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v2

- name: Install markdown-link-check
run: sudo npm install -g markdown-link-check@3.8.7
run: sudo npm install -g markdown-link-check@3

- name: Install and start docsify server
run: |
Expand Down
32 changes: 30 additions & 2 deletions etc/script/check-dead-link.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
#!/usr/bin/env bash

set -u

NC='\033[0m' # No Color
GREEN='\033[0;32m'
YELLOW='\033[0;33m'

for file in $(find . -name "*.md"); do
markdown-link-check -c .dlc.json -q "$file"
done
markdown-link-check -c .github/dead_link_check_config.json -q "$file" >> result.txt 2>&1
done

if [ -e result.txt ] ; then
cat result.txt
if grep -q "ERROR:" result.txt; then
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK RESULT<=========================${NC}"
printf "\n"
awk -F ' ' '/links checked/{sum+=$1}END{print "Total "sum" links checked.\n"}' result.txt
awk -F ' ' '/ERROR/{sum+=$2}END{print "[✖] Found "sum " dead links.\n"}' result.txt
echo -e "${YELLOW}=========================================================================${NC}"
exit 2
else
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK RESULT<=========================${NC}"
printf "\n"
awk -F ' ' '/links checked/{sum+=$1}END{print "Total "sum" links checked.\n"}' result.txt
echo -e "${GREEN}[✔] All links are good!${NC}"
echo -e "${YELLOW}=========================================================================${NC}"
fi
else
echo -e "${GREEN}No link need check!${NC}"
fi