Skip to content

Commit 820c058

Browse files
Merge pull request #36 from bflad/file-extension-configuration
Support file extension configuration
2 parents f194a07 + 5691ec6 commit 820c058

File tree

6 files changed

+52
-2
lines changed

6 files changed

+52
-2
lines changed

.github/workflows/push.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ on: [pull_request]
22
name: PR Checks
33
jobs:
44
markdown-link-check:
5+
strategy:
6+
matrix:
7+
file-extension: [.md, .markdown]
8+
fail-fast: false
59
runs-on: ubuntu-latest
610
steps:
711
- uses: actions/checkout@master
812
- name: markdown-link-check
913
uses: ./
1014
with:
1115
use-quiet-mode: 'yes'
16+
file-extension: ${{ matrix.file-extension }}
1217
folder-path: 'md'
1318
shellcheck:
1419
runs-on: [ubuntu-latest]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ You customize the action by using the following variables:
3939
|`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` |
4040
|`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`|
4141
|`base-branch`|Use this variable to specify the branch to compare when finding modified markdown files. |`master`|
42+
|`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`|
4243

4344
#### Sample workflow with variables
4445

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ inputs:
3636
finds the modififed files.'
3737
required: true
3838
default: 'master'
39+
file-extension:
40+
description: 'Use this to specify the file extension of Markdown files.'
41+
required: true
42+
default: '.md'
3943

4044
runs:
4145
using: 'docker'
@@ -48,3 +52,4 @@ runs:
4852
- ${{ inputs.max-depth }}
4953
- ${{ inputs.check-modified-files-only }}
5054
- ${{ inputs.base-branch }}
55+
- ${{ inputs.file-extension }}

entrypoint.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ FOLDER_PATH="$4"
1818
MAX_DEPTH="$5"
1919
CHECK_MODIFIED_FILES="$6"
2020
BASE_BRANCH="$7"
21+
FILE_EXTENSION="$8"
2122

2223
echo -e "${BLUE}USE_QUIET_MODE: $1${NC}"
2324
echo -e "${BLUE}USE_VERBOSE_MODE: $2${NC}"
2425
echo -e "${BLUE}FOLDER_PATH: $4${NC}"
2526
echo -e "${BLUE}MAX_DEPTH: $5${NC}"
2627
echo -e "${BLUE}CHECK_MODIFIED_FILES: $6${NC}"
28+
echo -e "${BLUE}FILE_EXTENSION: $8${NC}"
2729

2830
check_errors () {
2931
if [ -e error.txt ] ; then
@@ -119,9 +121,9 @@ if [ "$CHECK_MODIFIED_FILES" = "yes" ]; then
119121
else
120122

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

127129
if [ -f "$CONFIG_FILE" ]; then

md/file3.markdown

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
## Test internal and external links
3+
4+
www.google.com
5+
6+
<!-- markdown-link-check-disable-next-line -->
7+
[This is a broken link](https://www.exampleexample.cox)
8+
<!-- markdown-link-check-disable-next-line -->
9+
[This is another broken link](http://ignored-domain.com) but its ignored using a
10+
configuration file.
11+
12+
### Delta
13+
14+
This [exists](#delta).
15+
<!-- markdown-link-check-disable-next-line -->
16+
This [one does not](#does-not).
17+
References and definitions are [checked][delta].
18+
19+
### Echo
20+
21+
Headings in `readme.md` are [not checked](file3.markdown#echo).
22+
<!-- markdown-link-check-disable-next-line -->
23+
But [missing files are reported](missing-example.js).
24+
25+
[delta]: #delta

md/file4.markdown

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Checking more links
2+
3+
## Echo
4+
<!-- markdown-link-check-disable-next-line -->
5+
This [doesn't exists](#alpha).
6+
This [one does](#echo).
7+
8+
## Foxtrot
9+
10+
This is linked from file3.
11+
12+
## change

0 commit comments

Comments
 (0)