Added support for markdown-link-check config file

This commit is contained in:
Gaurav Nelson 2019-10-09 10:53:02 +10:00
parent 40c36e60d7
commit ba713a2119
3 changed files with 33 additions and 3 deletions

View File

@ -19,9 +19,15 @@ This GitHub action checks all Markdown files in your repository for broken links
fetch-depth: 1
- uses: gaurav-nelson/github-action-markdown-link-check@0.2.0
```
1. To use a [custom configuration](https://github.com/tcort/markdown-link-check#config-file-format)
for markdown-link-check, create a JSON configuration file and save it in the
root filder as `mlc_config.json`.
## Test links
www.google.com
[This is a broken link](www.exampleexample.cox)
[This is another broken link](http://ignored-domain.com) but its ignored using a
configuration file.

View File

@ -2,16 +2,33 @@
set -eu
NC='\033[0m' # No Color
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
npm i -g markdown-link-check
echo "=========================> MARKDOWN LINK CHECK <========================="
CONFIG_FILE=mlc_config.json
find . -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} \; 2> error.txt
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK <=========================${NC}"
echo "========================================================================="
if [ -f "$CONFIG_FILE" ]; then
echo -e "${BLUE}Using markdown-link-check configuration file: ${YELLOW}$CONFIG_FILE${NC}"
find . -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} --config "$CONFIG_FILE" \; 2> error.txt
else
echo -e "${BLUE}Cannot find ${YELLOW}$CONFIG_FILE${NC}"
echo -e "${YELLOW}NOTE: See https://github.com/tcort/markdown-link-check#config-file-format to know more about"
echo -e "customizing markdown-link-check by using a configuration file.${NC}"
find . -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} \; 2> error.txt
fi
echo -e "${YELLOW}=========================================================================${NC}"
if [ -e error.txt ] ; then
if grep -q "ERROR:" error.txt; then
exit 113
fi
else
echo -e "${GREEN}All good!${NC}"
fi

7
mlc_config.json Normal file
View File

@ -0,0 +1,7 @@
{
"ignorePatterns": [
{
"pattern": "^http://ignored-domain.com"
}
]
}