mirror of
https://github.com/gaurav-nelson/github-action-markdown-link-check.git
synced 2024-08-16 23:20:21 +03:00
Added internal links check, quite, verbose modes
This commit is contained in:
parent
3ff8996a53
commit
5559125f52
@ -1,4 +1,5 @@
|
||||
FROM node:alpine
|
||||
RUN apk add --no-cache bash
|
||||
ADD entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
20
README.md
20
README.md
@ -23,11 +23,27 @@ This GitHub action checks all Markdown files in your repository for broken links
|
||||
for markdown-link-check, create a JSON configuration file and save it in the
|
||||
root folder as `mlc_config.json`.
|
||||
|
||||
## Test links
|
||||
## Test internal and external links
|
||||
|
||||
www.google.com
|
||||
|
||||
[This is a broken link](www.exampleexample.cox)
|
||||
[This is a broken link](https://www.exampleexample.cox)
|
||||
|
||||
[This is another broken link](http://ignored-domain.com) but its ignored using a
|
||||
configuration file.
|
||||
|
||||
### Alpha
|
||||
|
||||
This [exists](#alpha).
|
||||
This [one does not](#does-not).
|
||||
References and definitions are [checked][alpha] [too][charlie].
|
||||
|
||||
### Bravo
|
||||
|
||||
Headings in `readme.md` are [not checked](readme.md#bravo).
|
||||
But [missing files are reported](missing-example.js).
|
||||
|
||||
[alpha]: #alpha
|
||||
[charlie]: #charlie
|
||||
|
||||
External file: [Charlie](./README2.md/#charlie)
|
10
README2.md
Normal file
10
README2.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Checking more links
|
||||
|
||||
## Bravo
|
||||
|
||||
This [doesn't exists](#alpha).
|
||||
This [one does](#bravo).
|
||||
|
||||
## Charlie
|
||||
|
||||
This is linked from README file.
|
19
action.yml
19
action.yml
@ -4,6 +4,25 @@ author: 'Gaurav Nelson'
|
||||
branding:
|
||||
icon: 'link'
|
||||
color: 'green'
|
||||
inputs:
|
||||
use-quite-mode:
|
||||
description: 'Use yes to enable markdown-link-check quite mode which only
|
||||
list errors.'
|
||||
required: true
|
||||
default: 'no'
|
||||
use-verbose-mode:
|
||||
description: 'Use yes to enable markdown-link-check verbose mode which lists
|
||||
additional details.'
|
||||
required: true
|
||||
default: 'no'
|
||||
config-file:
|
||||
description: 'Specify path to a markdown-link-check JSON configuration file.'
|
||||
required: true
|
||||
default: 'mlc_config.json'
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
args:
|
||||
- ${{ inputs.use-quite-mode }}
|
||||
- ${{ inputs.use-verbose-mode }}
|
||||
- ${{ inputs.config-file }}
|
||||
|
@ -9,24 +9,77 @@ BLUE='\033[0;34m'
|
||||
|
||||
npm i -g markdown-link-check
|
||||
|
||||
CONFIG_FILE=mlc_config.json
|
||||
USE_QUITE_MODE="$1"
|
||||
USE_VERBOSE_MODE="$2"
|
||||
CONFIG_FILE="$3"
|
||||
|
||||
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK <=========================${NC}"
|
||||
echo "USE_QUITE_MODE: $1"
|
||||
echo "USE_VERBOSE_MODE: $2"
|
||||
|
||||
if [ "$USE_QUITE_MODE" = "yes" ]; then
|
||||
|
||||
if [ "$USE_VERBOSE_MODE" = "yes" ]; then
|
||||
|
||||
if [ -f "$CONFIG_FILE" ]; then
|
||||
echo -e "${BLUE}I found config file ${NC}"
|
||||
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" -vq \; &>> 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 {} -vq \; &>> error.txt
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
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" -q \; &>> 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 {} -q \; &>> error.txt
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
if [ "$USE_VERBOSE_MODE" = "yes" ]; then
|
||||
|
||||
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" -v \; &>> 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 {} -v \; &>> error.txt
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
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" \; &>> 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 {} \; &>> error.txt
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
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
|
||||
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK <=========================${NC}"
|
||||
less error.txt
|
||||
echo -e "${YELLOW}=========================================================================${NC}"
|
||||
exit 113
|
||||
fi
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user