mirror of
https://github.com/gaurav-nelson/github-action-markdown-link-check.git
synced 2024-08-16 23:20:21 +03:00
fixed quite, improved output, added custom folder option
This commit is contained in:
parent
9d1134b1f7
commit
0f8975d33c
2
.github/workflows/push.yml
vendored
2
.github/workflows/push.yml
vendored
@ -7,3 +7,5 @@ jobs:
|
||||
- uses: actions/checkout@master
|
||||
- name: markdown-link-check
|
||||
uses: ./
|
||||
with:
|
||||
use-quiet-mode: 'yes'
|
||||
|
21
README.md
21
README.md
@ -3,7 +3,7 @@ This GitHub action checks all Markdown files in your repository for broken links
|
||||
|
||||
## How to use
|
||||
1. Create a new file in your repository `.github/workflows/action.yml`.
|
||||
1. Copy-paste the folloing workflow in your `action.yml` file:
|
||||
1. Copy-paste the following workflow in your `action.yml` file:
|
||||
|
||||
```yml
|
||||
name: Check Markdown links
|
||||
@ -19,9 +19,7 @@ This GitHub action checks all Markdown files in your repository for broken links
|
||||
fetch-depth: 1
|
||||
- uses: gaurav-nelson/github-action-markdown-link-check@0.5.0
|
||||
```
|
||||
1. If you want to use a [custom configuration](https://github.com/tcort/markdown-link-check#config-file-format)
|
||||
for markdown-link-check, or use the `--verbose` or `--quite` options, use the
|
||||
`config-file`, `use-quite-mode`, and `use-verbose-mode` variables as follows:
|
||||
1. Or you can use the action with [variables](#available-variables) as follows:
|
||||
|
||||
```yml
|
||||
name: Check Markdown links
|
||||
@ -37,11 +35,24 @@ This GitHub action checks all Markdown files in your repository for broken links
|
||||
fetch-depth: 1
|
||||
- uses: gaurav-nelson/github-action-markdown-link-check@0.5.0
|
||||
with:
|
||||
use-quite-mode: 'yes'
|
||||
use-quiet-mode: 'yes'
|
||||
use-verbose-mode: 'yes'
|
||||
config-file: 'mlc_config.json'
|
||||
folder-path: 'docs/markdown_files'
|
||||
```
|
||||
|
||||
### Available variables
|
||||
|
||||
- `use-quiet-mode`: Specify `yes` to only show errors in output.
|
||||
- `use-verbose-mode`: Specify `yes` to show detailed HTTP status for checked links.
|
||||
- `config-file`: Specify a [custom configuration
|
||||
file](https://github.com/tcort/markdown-link-check#config-file-format) for
|
||||
markdown-link-check. You can use it to remove false-positives by specifying
|
||||
replacement patterns and ignore patterns.
|
||||
- `folder-path`: By default the `github-action-markdown-link-check` action
|
||||
checks for all markdown files in your repository. Use this option to limit
|
||||
checks to only specific folders.
|
||||
|
||||
## Test internal and external links
|
||||
|
||||
www.google.com
|
||||
|
11
action.yml
11
action.yml
@ -5,8 +5,8 @@ branding:
|
||||
icon: 'link'
|
||||
color: 'green'
|
||||
inputs:
|
||||
use-quite-mode:
|
||||
description: 'Use yes to enable markdown-link-check quite mode which only
|
||||
use-quiet-mode:
|
||||
description: 'Use yes to enable markdown-link-check quiet mode which only
|
||||
list errors.'
|
||||
required: true
|
||||
default: 'no'
|
||||
@ -19,10 +19,15 @@ inputs:
|
||||
description: 'Specify path to a markdown-link-check JSON configuration file.'
|
||||
required: true
|
||||
default: 'mlc_config.json'
|
||||
folder-path:
|
||||
description: 'Specify path to a custom folder where your markdown files are located.'
|
||||
required: true
|
||||
default: '.'
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
args:
|
||||
- ${{ inputs.use-quite-mode }}
|
||||
- ${{ inputs.use-quiet-mode }}
|
||||
- ${{ inputs.use-verbose-mode }}
|
||||
- ${{ inputs.config-file }}
|
||||
- ${{ inputs.folder-path }}
|
||||
|
@ -9,38 +9,48 @@ BLUE='\033[0;34m'
|
||||
|
||||
npm i -g markdown-link-check
|
||||
|
||||
USE_QUITE_MODE="$1"
|
||||
USE_QUIET_MODE="$1"
|
||||
USE_VERBOSE_MODE="$2"
|
||||
CONFIG_FILE="$3"
|
||||
FOLDER_PATH="$4"
|
||||
|
||||
echo "USE_QUITE_MODE: $1"
|
||||
echo "USE_VERBOSE_MODE: $2"
|
||||
echo -e "${BLUE}USE_QUIET_MODE: $1${NC}"
|
||||
echo -e "${BLUE}USE_VERBOSE_MODE: $2${NC}"
|
||||
echo -e "${BLUE}FOLDER_PATH: $4${NC}"
|
||||
|
||||
if [ "$USE_QUITE_MODE" = "yes" ]; then
|
||||
if [ "$USE_QUIET_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
|
||||
set -x
|
||||
find "$FOLDER_PATH" -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} --config "$CONFIG_FILE" -vq \; &>> error.txt
|
||||
set +x
|
||||
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
|
||||
set -x
|
||||
find "$FOLDER_PATH" -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} -vq \; &>> error.txt
|
||||
set +x
|
||||
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
|
||||
set -x
|
||||
find "$FOLDER_PATH" -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} --config "$CONFIG_FILE" -q \; &>> error.txt
|
||||
set +x
|
||||
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
|
||||
set -x
|
||||
find "$FOLDER_PATH" -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} -q \; &>> error.txt
|
||||
set +x
|
||||
fi
|
||||
|
||||
fi
|
||||
@ -51,24 +61,32 @@ 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" -v \; &>> error.txt
|
||||
set -x
|
||||
find "$FOLDER_PATH" -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} --config "$CONFIG_FILE" -v \; &>> error.txt
|
||||
set +x
|
||||
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
|
||||
set -x
|
||||
find "$FOLDER_PATH" -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} -v \; &>> error.txt
|
||||
set +x
|
||||
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
|
||||
set -x
|
||||
find "$FOLDER_PATH" -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} --config "$CONFIG_FILE" \; &>> error.txt
|
||||
set +x
|
||||
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
|
||||
set -x
|
||||
find "$FOLDER_PATH" -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} \; &>> error.txt
|
||||
set +x
|
||||
fi
|
||||
|
||||
fi
|
||||
@ -78,9 +96,16 @@ fi
|
||||
if [ -e error.txt ] ; then
|
||||
if grep -q "ERROR:" error.txt; then
|
||||
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK <=========================${NC}"
|
||||
less error.txt
|
||||
cat error.txt
|
||||
printf "\n"
|
||||
echo -e "${YELLOW}=========================================================================${NC}"
|
||||
exit 113
|
||||
else
|
||||
echo -e "${YELLOW}=========================> MARKDOWN LINK CHECK <=========================${NC}"
|
||||
printf "\n"
|
||||
echo -e "${GREEN}[✔] All links are good!${NC}"
|
||||
printf "\n"
|
||||
echo -e "${YELLOW}=========================================================================${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}All good!${NC}"
|
||||
|
Loading…
Reference in New Issue
Block a user