Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
mloberg committed Mar 25, 2021
0 parents commit f7dfcc8
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/problem-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"problemMatcher": [
{
"owner": "markdownlint",
"pattern": [
{
"regexp": "^([^:]*):(\\d+):?(\\d+)?\\s([\\w-\\/]*)\\s(.*)$",
"file": 1,
"line": 2,
"column": 3,
"code": 4,
"message": 5
}
]
}
]
}
15 changes: 15 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Main

on:
push:
branches:
- main
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: shellcheck entrypoint.sh
- uses: ./
20 changes: 20 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"default": true,
"MD003": {
"style": "atx"
},
"MD004": {
"style": "asterisk"
},
"MD013": {
"code_blocks": false,
"tables": false
},
"MD033": {
"allowed_elements": [
"details",
"summary"
]
},
"MD046": false
}
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:lts-alpine

COPY entrypoint.sh .github/problem-matcher.json .markdownlint.json /

RUN npm install --global --production markdownlint-cli

ENTRYPOINT ["/entrypoint.sh"]
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# markdownlint action

This action lints your Markdown files with [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli).

## Usage

Including the action without any defaults will find a local markdownlint config
file (`.markdownlint.{yaml,yml,json}`) or use our included default and scan all
files with the `md` or `markdown` extension.

```yaml
- uses: articulate/actions-markdownlint@main
```
You can set the config file, the files it scans, or files/directories to ignore.
```yaml
- uses: articulate/actions-markdownlint@main
with:
config: markdownlint-config.json
files: 'docs/**/*.md'
ignore: node_modules
```
23 changes: 23 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'markdownlint'
author: 'Articulate'
description: 'Lint your markdown'
inputs:
config:
description: 'markdownlint config file'
required: false
files:
description: 'Markdown files to scan'
required: false
default: '**/*.{md,markdown}'
ignore:
description: 'Files or directories to ignore'
required: false
fix:
description: 'Try to fix basic errors'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
branding:
color: 'blue'
icon: 'check-circle'
36 changes: 36 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

# Copy the matcher to a shared volume with the host; otherwise "add-matcher"
# can't find it.
cp /problem-matcher.json "${HOME}/markdownlint-problem-matcher.json"
echo "::add-matcher::${HOME}/markdownlint-problem-matcher.json"

MARKDOWNLINT=

if [ -z "$INPUT_CONFIG" ]; then
echo "::debug::no config given, finding suitable config"
INPUT_CONFIG=/.markdownlint.json
for cfg in .markdownlint.yaml .markdownlint.yml .markdownlint.json .markdown-lint.yml .markdown-lint.json; do
if [ -f "$cfg" ]; then
INPUT_CONFIG="$cfg"
continue
fi
done
fi

echo "::debug::using config ${INPUT_CONFIG}"
MARKDOWNLINT="${MARKDOWNLINT} --config ${INPUT_CONFIG}"

if [ -n "$INPUT_IGNORE" ]; then
echo "::debug::ignoring ${INPUT_IGNORE}"
MARKDOWNLINT="${MARKDOWNLINT} --ignore ${INPUT_IGNORE}"
fi

if [ -n "$INPUT_FIX" ]; then
echo "::debug::attempting to fix input"
MARKDOWNLINT="${MARKDOWNLINT} --fix"
fi

echo "::debug::linting ${INPUT_FILES}"
# shellcheck disable=SC2086
markdownlint ${MARKDOWNLINT} ${INPUT_FILES}

0 comments on commit f7dfcc8

Please sign in to comment.