mirror of
https://github.com/gaurav-nelson/github-action-markdown-link-check.git
synced 2024-10-05 15:08:01 +03:00
Added support for markdown-link-check config file
This commit is contained in:
parent
40c36e60d7
commit
ba713a2119
@ -19,9 +19,15 @@ This GitHub action checks all Markdown files in your repository for broken links
|
|||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
- uses: gaurav-nelson/github-action-markdown-link-check@0.2.0
|
- 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
|
## Test links
|
||||||
|
|
||||||
www.google.com
|
www.google.com
|
||||||
|
|
||||||
[This is a broken link](www.exampleexample.cox)
|
[This is a broken link](www.exampleexample.cox)
|
||||||
|
|
||||||
|
[This is another broken link](http://ignored-domain.com) but its ignored using a
|
||||||
|
configuration file.
|
||||||
|
@ -2,16 +2,33 @@
|
|||||||
|
|
||||||
set -eu
|
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
|
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 [ -e error.txt ] ; then
|
||||||
if grep -q "ERROR:" error.txt; then
|
if grep -q "ERROR:" error.txt; then
|
||||||
exit 113
|
exit 113
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}All good!${NC}"
|
||||||
fi
|
fi
|
||||||
|
7
mlc_config.json
Normal file
7
mlc_config.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"ignorePatterns": [
|
||||||
|
{
|
||||||
|
"pattern": "^http://ignored-domain.com"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user