Skip to content

Commit 7399cff

Browse files
Merge pull request #4 from gaurav-nelson/support-mlc-config
Added support for markdown-link-check config file
2 parents 40c36e6 + 270a083 commit 7399cff

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ This GitHub action checks all Markdown files in your repository for broken links
1717
- uses: actions/checkout@master
1818
with:
1919
fetch-depth: 1
20-
- uses: gaurav-nelson/github-action-markdown-link-check@0.2.0
20+
- uses: gaurav-nelson/github-action-markdown-link-check@0.3.0
2121
```
22+
1. To use a [custom configuration](https://github.com/tcort/markdown-link-check#config-file-format)
23+
for markdown-link-check, create a JSON configuration file and save it in the
24+
root filder as `mlc_config.json`.
2225

2326
## Test links
2427

2528
www.google.com
2629

2730
[This is a broken link](www.exampleexample.cox)
31+
32+
[This is another broken link](http://ignored-domain.com) but its ignored using a
33+
configuration file.

entrypoint.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,33 @@
22

33
set -eu
44

5+
NC='\033[0m' # No Color
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[0;33m'
8+
BLUE='\033[0;34m'
9+
510
npm i -g markdown-link-check
611

7-
echo "=========================> MARKDOWN LINK CHECK <========================="
12+
CONFIG_FILE=mlc_config.json
13+
14+
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK <=========================${NC}"
815

9-
find . -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} \; 2> error.txt
16+
if [ -f "$CONFIG_FILE" ]; then
17+
echo -e "${BLUE}Using markdown-link-check configuration file: ${YELLOW}$CONFIG_FILE${NC}"
18+
find . -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} --config "$CONFIG_FILE" \; 2> error.txt
19+
else
20+
echo -e "${BLUE}Cannot find ${YELLOW}$CONFIG_FILE${NC}"
21+
echo -e "${YELLOW}NOTE: See https://github.com/tcort/markdown-link-check#config-file-format to know more about"
22+
echo -e "customizing markdown-link-check by using a configuration file.${NC}"
23+
find . -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} \; 2> error.txt
24+
fi
1025

11-
echo "========================================================================="
26+
echo -e "${YELLOW}=========================================================================${NC}"
1227

1328
if [ -e error.txt ] ; then
1429
if grep -q "ERROR:" error.txt; then
1530
exit 113
1631
fi
32+
else
33+
echo -e "${GREEN}All good!${NC}"
1734
fi

mlc_config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^http://ignored-domain.com"
5+
}
6+
]
7+
}

0 commit comments

Comments
 (0)