Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array check #29

Merged
merged 4 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
on: push
name: New workflow
on:
push:
branches:
- master
pull_request:
branches:
- master
name: Link Check
jobs:
markdown-link-check:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ You cancustomize the action by using the following variables:
- `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.
- `max-depth`: Specify how many levels deep you want to check in the directory
structure. By default this is not set, using e.g. `1` will limit to
top-level directory only or `folder-path` only, if set.

#### Sample workflow with variables

Expand All @@ -55,6 +58,7 @@ jobs:
use-verbose-mode: 'yes'
config-file: 'mlc_config.json'
folder-path: 'docs/markdown_files'
max-depth: 2
```

### Scheduled runs
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ inputs:
description: 'Specify path to a custom folder where your markdown files are located.'
required: true
default: '.'
max-depth:
description: 'Specify a max-depth of directories you want to search for markdown files.'
required: true
default: '-1'
runs:
using: 'docker'
image: 'Dockerfile'
Expand All @@ -31,3 +35,4 @@ runs:
- ${{ inputs.use-verbose-mode }}
- ${{ inputs.config-file }}
- ${{ inputs.folder-path }}
- ${{ inputs.max-depth }}
92 changes: 25 additions & 67 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,85 +13,43 @@ USE_QUIET_MODE="$1"
USE_VERBOSE_MODE="$2"
CONFIG_FILE="$3"
FOLDER_PATH="$4"
MAX_DEPTH="$5"

echo -e "${BLUE}USE_QUIET_MODE: $1${NC}"
echo -e "${BLUE}USE_VERBOSE_MODE: $2${NC}"
echo -e "${BLUE}FOLDER_PATH: $4${NC}"
echo -e "${BLUE}MAX_DEPTH: $5${NC}"

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}"
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}"
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}"
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}"
set -x
find "$FOLDER_PATH" -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} -q \; &>> error.txt
set +x
fi

fi
declare -a FIND_CALL

if [ "$5" -ne -1 ]; then
FIND_CALL=('find' "${FOLDER_PATH}" '-name' '*.md' '-not' '-path' './node_modules/*' '-maxdepth' "${MAX_DEPTH}" '-exec' 'markdown-link-check' '{}')
else
FIND_CALL=('find' "${FOLDER_PATH}" '-name' '*.md' '-not' '-path' './node_modules/*' '-exec' 'markdown-link-check' '{}')
fi

if [ "$USE_VERBOSE_MODE" = "yes" ]; then

if [ -f "$CONFIG_FILE" ]; then
echo -e "${BLUE}Using markdown-link-check configuration file: ${YELLOW}$CONFIG_FILE${NC}"
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}"
set -x
find "$FOLDER_PATH" -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} -v \; &>> error.txt
set +x
fi
if [ -f "$CONFIG_FILE" ]; then
echo -e "${BLUE}Using markdown-link-check configuration file: ${YELLOW}$CONFIG_FILE${NC}"
FIND_CALL+=('--config' "${CONFIG_FILE}")
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}"
fi

else
if [ "$USE_QUIET_MODE" = "yes" ]; then
FIND_CALL+=('-q')
fi

if [ -f "$CONFIG_FILE" ]; then
echo -e "${BLUE}Using markdown-link-check configuration file: ${YELLOW}$CONFIG_FILE${NC}"
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}"
set -x
find "$FOLDER_PATH" -name \*.md -not -path "./node_modules/*" -exec markdown-link-check {} \; &>> error.txt
set +x
fi
if [ "$USE_VERBOSE_MODE" = "yes" ]; then
FIND_CALL+=('-v')
fi

fi
FIND_CALL+=(';')

fi
set -x
"${FIND_CALL[@]}" &>> error.txt
set +x

if [ -e error.txt ] ; then
if grep -q "ERROR:" error.txt; then
Expand Down
25 changes: 25 additions & 0 deletions md/md-level-1/level-1a.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

## Test internal and external links

www.google.com

[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](file1.md#bravo).
But [missing files are reported](missing-example.js).

[alpha]: #alpha
[charlie]: #charlie

External file: [Charlie](./file2.md/#charlie)
10 changes: 10 additions & 0 deletions md/md-level-1/level-1b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Checking more links

## Bravo

This [doesn't exists](#alpha).
This [one does](#bravo).

## Charlie

This is linked from file1.
25 changes: 25 additions & 0 deletions md/md-level-1/md-level-2/level-2a.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

## Test internal and external links

www.google.com

[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](file1.md#bravo).
But [missing files are reported](missing-example.js).

[alpha]: #alpha
[charlie]: #charlie

External file: [Charlie](./file2.md/#charlie)
10 changes: 10 additions & 0 deletions md/md-level-1/md-level-2/level-2b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Checking more links

## Bravo

This [doesn't exists](#alpha).
This [one does](#bravo).

## Charlie

This is linked from file1.