Skip to content
Snippets Groups Projects
Commit 5a89b377 authored by Jared Kosanovic's avatar Jared Kosanovic
Browse files

Check for broken links - INPLATFORM 219

parent 4b1a23fb
No related branches found
No related tags found
No related merge requests found
check-links:
stage: test
tags:
- docker
image: "node:14"
before_script:
- npm install -g markdown-link-check
script:
- cd scripts
- ./link-checker.sh
# Scripts
## Link Checker
Files:
- [link-checker.sh](./link-checker.sh): Main script to check each markdown file for broken external links and relative links. Uses [markdown-link-check](https://www.npmjs.com/package/markdown-link-check).
- [link-checker-config.json](./link-checker-config.json): Configuration file for [markdown-link-check](https://www.npmjs.com/package/markdown-link-check). Used to exclude certain links so that they are not checked. This could be done for example links or links to websites that are sometimes down or timeout.
\ No newline at end of file
{
"ignorePatterns": [
{
"pattern": "interop.it.wisc.edu"
}
]
}
exit_code=0
# Find all markdown files
markdown_files=$(find ../ -name \*.md)
for markdown_file in $markdown_files; do
# For each markdown file, check the links. link-checker-config.json excludes certain links (like example.com)
# If broken links are found, output them along with the file path.
if markdown-link-check -q -c link-checker-config.json $markdown_file > links.log; then
# Do nothing if the file doesn't have any broken links.
:
else
# If broken links are found, output them along with the file path.
cat links.log
exit_code=1
fi
rm links.log
done
exit $exit_code
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment