Skip to content

Commit

Permalink
Merge pull request #4 from gaurav-nelson/support-mlc-config
Browse files Browse the repository at this point in the history
Added support for markdown-link-check config file
  • Loading branch information
gaurav-nelson committed Oct 9, 2019
2 parents 40c36e6 + 270a083 commit 7399cff
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
23 changes: 20 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK <=========================${NC}"

find . -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} \; 2> error.txt
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 "========================================================================="
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 changes: 7 additions & 0 deletions mlc_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ignorePatterns": [
{
"pattern": "^http://ignored-domain.com"
}
]
}

0 comments on commit 7399cff

Please sign in to comment.