Skip to content

Commit 25fed1d

Browse files
committed
Add disable, dot, and enable inputs
1 parent ec9432f commit 25fed1d

7 files changed

Lines changed: 54 additions & 21 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: CI
33

4-
on: # yamllint disable-line rule:truthy
4+
on:
55
pull_request:
66
branches:
77
- master
@@ -30,7 +30,7 @@ jobs:
3030
id: expect-failure
3131
uses: ./
3232
with:
33-
config_file: .markdownlintrc
33+
config: .markdownlintrc
3434
files: .
3535
rules: examples/rules/custom.js
3636
env:
@@ -42,18 +42,18 @@ jobs:
4242
- name: Test ignore_files
4343
uses: ./
4444
with:
45-
config_file: .markdownlintrc
45+
config: .markdownlintrc
4646
files: .
47-
ignore_files: examples/ignore/*
47+
ignore: examples/ignore/*
4848
rules: examples/rules/custom.js
4949
env:
5050
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5151
- name: Test ignore_path
5252
uses: ./
5353
with:
54-
config_file: .markdownlintrc
54+
config: .markdownlintrc
5555
files: .
56-
ignore_path: examples/.markdownlintignore
56+
ignore-path: examples/.markdownlintignore
5757
rules: examples/rules/custom.js
5858
env:
5959
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Release
33

4-
on: # yamllint disable-line rule:truthy
4+
on:
55
push:
66
tags:
77
- v*.*.*

.github/workflows/versioning.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: Tag Versioning
33

4-
on: # yamllint disable-line rule:truthy
4+
on:
55
release:
66
types:
77
- published

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ repos:
2929
- --config-file=.yamllint
3030
- --strict
3131

32-
- repo: https://github.com/rhysd/actionlint
33-
rev: v1.6.13
34-
hooks:
35-
- id: actionlint
36-
3732
minimum_pre_commit_version: !!str 2.19

.yamllint

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ rules:
1212
present: false
1313
indentation:
1414
spaces: 2
15-
indent-sequences: true
1615
line-length:
1716
allow-non-breakable-words: true
1817
allow-non-breakable-inline-mappings: true
@@ -21,3 +20,5 @@ rules:
2120
quoted-strings:
2221
quote-type: double
2322
required: only-when-needed
23+
truthy:
24+
check-keys: false

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,24 @@ Basic usage with all options enabled:
1313
- name: markdownlint-cli
1414
uses: nosborn/github-action-markdown-cli@v4.0.0
1515
with:
16-
cli-version: latest
17-
config-file: .markdownlint.yaml
1816
files: .
17+
config-file: .markdownlint.yaml
18+
disable: MD013 MD041
19+
dot: true
20+
enable: MD013 MD041
1921
ignore-files: examples/ignore/*
2022
ignore-path: examples/.markdownlintignore
2123
rules: examples/rules/custom.js
24+
cli-version: latest
2225
```
2326
2427
## Inputs
2528
2629
- `files` - what to process (files, directories, globs)
2730
- `config` (optional) - configuration file (JSON or YAML)
31+
- `disable` (optional) - disable certain rules, for example `MD013 MD041`
32+
- `dot` (optional) - if `true`, include files/folders with a dot (for example `.github`)
33+
- `enable` (optional) - enable certain rules, for example `MD013 MD041`
2834
- `ignore` (optional) - files to ignore/exclude (file, directory, glob)
2935
- `ignore-path` (optional) - path to file with ignore patterns
3036
- `rules` (optional) - custom rule files (file, directory, glob, package)

action.yml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ inputs:
1616
description: configuration file (JSON or YAML)
1717
required: false
1818
deprecationMessage: Please use 'config' instead.
19+
disable:
20+
description: enable certain rules, for example 'MD013 MD041'
21+
required: false
22+
dot:
23+
description: if 'true', include files/folders with a dot (for example '.github')
24+
required: false
25+
enable:
26+
description: enable certain rules, for example 'MD013 MD041'
27+
required: false
1928
files:
2029
description: files, directories, or globs
2130
required: true
@@ -25,14 +34,14 @@ inputs:
2534
ignore-path:
2635
description: path to file with ignore pattern(s)
2736
required: false
28-
deprecationMessage: Please use 'ignore-path' instead.
2937
ignore_files:
3038
description: files to ignore/exclude
3139
required: false
3240
deprecationMessage: Please use 'ignore' instead.
3341
ignore_path:
3442
description: path to file with ignore pattern(s)
3543
required: false
44+
deprecationMessage: Please use 'ignore-path' instead.
3645
rules:
3746
description: custom rule files
3847
required: false
@@ -43,17 +52,36 @@ runs:
4352
- run: |
4453
echo '::group::Installing markdownlint-cli'
4554
version="$(npm view --json markdownlint-cli@${INPUT_CLI_VERSION:?} | jq -r .version)"
55+
major_version="$(cut -d . -f 1 <<<"${version}")"
56+
minor_version="$(cut -d . -f 2 <<<"${version}")"
4657
prefix="${RUNNER_TOOL_CACHE:-${RUNNER_TEMP:?}}/markdownlint-cli/${version}"
4758
mkdir -p "${prefix}"
4859
# FIXME: --global and --production are deprecated
4960
NPM_CONFIG_PREFIX="${prefix}" npm install --global --production "markdownlint-cli@${version}"
5061
echo '::endgroup::'
5162
5263
markdownlint="${prefix}/bin/markdownlint"
53-
markdownlint="${markdownlint}${INPUT_CONFIG_FILE:+ -c ${INPUT_CONFIG_FILE:?}}"
54-
markdownlint="${markdownlint}${INPUT_IGNORE:+ -i ${INPUT_IGNORE:?}}"
55-
markdownlint="${markdownlint}${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH:?}}"
56-
markdownlint="${markdownlint}${INPUT_RULES:+ -r ${INPUT_RULES:?}}"
64+
markdownlint+="${INPUT_CONFIG_FILE:+ -c ${INPUT_CONFIG_FILE:?}}"
65+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 30 ]]; then
66+
markdownlint+="${INPUT_DISABLE:+ --disable ${INPUT_DISABLE:?}}"
67+
fi
68+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 27 ]]; then
69+
if [[ "$(tr '[:upper:]' '[:lower:]' <<<"${INPUT_DOT}")" == true ]]; then
70+
markdownlint+=' --dot'
71+
fi
72+
fi
73+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 30 ]]; then
74+
markdownlint+="${INPUT_ENABLE:+ --enable ${INPUT_ENABLE:?}}"
75+
fi
76+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 7 ]]; then
77+
markdownlint+="${INPUT_IGNORE:+ -i ${INPUT_IGNORE:?}}"
78+
fi
79+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 22 ]]; then
80+
markdownlint+="${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH:?}}"
81+
fi
82+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 11 ]]; then
83+
markdownlint+="${INPUT_RULES:+ -r ${INPUT_RULES:?}}"
84+
fi
5785
5886
echo "::add-matcher::${GITHUB_ACTION_PATH:?}/markdownlint-problem-matcher.json"
5987
# shellcheck disable=SC2086
@@ -65,6 +93,9 @@ runs:
6593
env:
6694
INPUT_CLI_VERSION: ${{ inputs.cli-version }}
6795
INPUT_CONFIG_FILE: ${{ inputs.config || inputs.config_file }}
96+
INPUT_DISABLE: ${{ inputs.disable }}
97+
INPUT_DOT: ${{ inputs.dot }}
98+
INPUT_ENABLE: ${{ inputs.enable }}
6899
INPUT_FILES: ${{ inputs.files }}
69100
INPUT_IGNORE: ${{ inputs.ignore || inputs.ignore_files }}
70101
INPUT_IGNORE_PATH: ${{ inputs.ignore-path || inputs.ignore_path }}

0 commit comments

Comments
 (0)