Merge pull request #4 from gaurav-nelson/support-mlc-config

Added support for markdown-link-check config file
This commit is contained in:
Gaurav Nelson 2019-10-09 10:57:03 +10:00 committed by GitHub
commit 7399cff7db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 4 deletions

View File

@ -17,11 +17,17 @@ This GitHub action checks all Markdown files in your repository for broken links
- uses: actions/checkout@master
with:
fetch-depth: 1
- uses: gaurav-nelson/github-action-markdown-link-check@0.2.0
- uses: gaurav-nelson/github-action-markdown-link-check@0.3.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"
}
]
}