mirror of
https://github.com/gaurav-nelson/github-action-markdown-link-check.git
synced 2024-11-25 19:13:43 +03:00
Merge pull request #36 from bflad/file-extension-configuration
Support file extension configuration
This commit is contained in:
commit
820c058164
5
.github/workflows/push.yml
vendored
5
.github/workflows/push.yml
vendored
@ -2,6 +2,10 @@ on: [pull_request]
|
||||
name: PR Checks
|
||||
jobs:
|
||||
markdown-link-check:
|
||||
strategy:
|
||||
matrix:
|
||||
file-extension: [.md, .markdown]
|
||||
fail-fast: false
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
@ -9,6 +13,7 @@ jobs:
|
||||
uses: ./
|
||||
with:
|
||||
use-quiet-mode: 'yes'
|
||||
file-extension: ${{ matrix.file-extension }}
|
||||
folder-path: 'md'
|
||||
shellcheck:
|
||||
runs-on: [ubuntu-latest]
|
||||
|
@ -39,6 +39,7 @@ You customize the action by using the following variables:
|
||||
|`max-depth` |Specify how many levels deep you want to check in the directory structure. The default value is `-1` which means check all levels.|`-1` |
|
||||
|`check-modified-files-only` |Use this variable to only check modified markdown files instead of checking all markdown files. The action uses `git` to find modified markdown files. Only use this variable when you run the action to check pull requests.|`no`|
|
||||
|`base-branch`|Use this variable to specify the branch to compare when finding modified markdown files. |`master`|
|
||||
|`file-extension`|By default the `github-action-markdown-link-check` action checks files in your repository with the `.md` extension. Use this option to specify a different file extension such as `.markdown` or `.mdx`.|`.md`|
|
||||
|
||||
#### Sample workflow with variables
|
||||
|
||||
|
@ -36,6 +36,10 @@ inputs:
|
||||
finds the modififed files.'
|
||||
required: true
|
||||
default: 'master'
|
||||
file-extension:
|
||||
description: 'Use this to specify the file extension of Markdown files.'
|
||||
required: true
|
||||
default: '.md'
|
||||
|
||||
runs:
|
||||
using: 'docker'
|
||||
@ -48,3 +52,4 @@ runs:
|
||||
- ${{ inputs.max-depth }}
|
||||
- ${{ inputs.check-modified-files-only }}
|
||||
- ${{ inputs.base-branch }}
|
||||
- ${{ inputs.file-extension }}
|
||||
|
@ -18,12 +18,14 @@ FOLDER_PATH="$4"
|
||||
MAX_DEPTH="$5"
|
||||
CHECK_MODIFIED_FILES="$6"
|
||||
BASE_BRANCH="$7"
|
||||
FILE_EXTENSION="$8"
|
||||
|
||||
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}"
|
||||
echo -e "${BLUE}CHECK_MODIFIED_FILES: $6${NC}"
|
||||
echo -e "${BLUE}FILE_EXTENSION: $8${NC}"
|
||||
|
||||
check_errors () {
|
||||
if [ -e error.txt ] ; then
|
||||
@ -119,9 +121,9 @@ if [ "$CHECK_MODIFIED_FILES" = "yes" ]; then
|
||||
else
|
||||
|
||||
if [ "$5" -ne -1 ]; then
|
||||
FIND_CALL=('find' "${FOLDER_PATH}" '-name' '*.md' '-not' '-path' './node_modules/*' '-maxdepth' "${MAX_DEPTH}" '-exec' 'markdown-link-check' '{}')
|
||||
FIND_CALL=('find' "${FOLDER_PATH}" '-name' '*'"${FILE_EXTENSION}" '-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' '{}')
|
||||
FIND_CALL=('find' "${FOLDER_PATH}" '-name' '*'"${FILE_EXTENSION}" '-not' '-path' './node_modules/*' '-exec' 'markdown-link-check' '{}')
|
||||
fi
|
||||
|
||||
if [ -f "$CONFIG_FILE" ]; then
|
||||
|
25
md/file3.markdown
Normal file
25
md/file3.markdown
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
## Test internal and external links
|
||||
|
||||
www.google.com
|
||||
|
||||
<!-- markdown-link-check-disable-next-line -->
|
||||
[This is a broken link](https://www.exampleexample.cox)
|
||||
<!-- markdown-link-check-disable-next-line -->
|
||||
[This is another broken link](http://ignored-domain.com) but its ignored using a
|
||||
configuration file.
|
||||
|
||||
### Delta
|
||||
|
||||
This [exists](#delta).
|
||||
<!-- markdown-link-check-disable-next-line -->
|
||||
This [one does not](#does-not).
|
||||
References and definitions are [checked][delta].
|
||||
|
||||
### Echo
|
||||
|
||||
Headings in `readme.md` are [not checked](file3.markdown#echo).
|
||||
<!-- markdown-link-check-disable-next-line -->
|
||||
But [missing files are reported](missing-example.js).
|
||||
|
||||
[delta]: #delta
|
12
md/file4.markdown
Normal file
12
md/file4.markdown
Normal file
@ -0,0 +1,12 @@
|
||||
# Checking more links
|
||||
|
||||
## Echo
|
||||
<!-- markdown-link-check-disable-next-line -->
|
||||
This [doesn't exists](#alpha).
|
||||
This [one does](#echo).
|
||||
|
||||
## Foxtrot
|
||||
|
||||
This is linked from file3.
|
||||
|
||||
## change
|
Loading…
Reference in New Issue
Block a user