├── .github └── workflows │ ├── depup.yml │ ├── dockerimage.yml │ ├── release.yml │ └── reviewdog.yml ├── Dockerfile ├── LICENSE ├── README.md ├── _testdata └── test.md ├── action.yml ├── entrypoint.sh └── renovate.json /.github/workflows/depup.yml: -------------------------------------------------------------------------------- 1 | name: depup 2 | on: 3 | schedule: 4 | - cron: '14 14 * * *' # Runs at 14:14 UTC every day 5 | repository_dispatch: 6 | types: [depup] 7 | workflow_dispatch: 8 | 9 | jobs: 10 | markdownlint-cli: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 14 | - uses: haya14busa/action-depup@94a1aaf4e4923064019214b48a43276218af7ad5 # v1.6.4 15 | id: depup 16 | with: 17 | file: Dockerfile 18 | version_name: MARKDOWNLINT_CLI_VERSION 19 | repo: igorshubovych/markdownlint-cli 20 | 21 | - name: Create Pull Request 22 | uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 23 | with: 24 | token: ${{ secrets.GITHUB_TOKEN }} 25 | title: "chore(deps): update markdownlint-cli to ${{ steps.depup.outputs.latest }}" 26 | commit-message: "chore(deps): update markdownlint-cli to ${{ steps.depup.outputs.latest }}" 27 | body: | 28 | Update markdownlint-cli to [v${{ steps.depup.outputs.latest }}](https://github.com/igorshubovych/markdownlint-cli/tag/v${{ steps.depup.outputs.latest }}) 29 | Compare [v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}](https://github.com/igorshubovych/markdownlint-cli/compare/v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}) 30 | 31 | This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup). 32 | branch: depup/markdownlint-cli 33 | base: master 34 | labels: "bump:minor" 35 | 36 | reviewdog: 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 40 | - uses: haya14busa/action-depup@94a1aaf4e4923064019214b48a43276218af7ad5 # v1.6.4 41 | id: depup 42 | with: 43 | file: Dockerfile 44 | version_name: REVIEWDOG_VERSION 45 | repo: reviewdog/reviewdog 46 | 47 | - name: Create Pull Request 48 | uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 49 | with: 50 | token: ${{ secrets.GITHUB_TOKEN }} 51 | title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 52 | commit-message: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 53 | body: | 54 | Update reviewdog to [v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/releases/tag/v${{ steps.depup.outputs.latest }}) 55 | Compare [v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/compare/v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}) 56 | 57 | This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup). 58 | branch: depup/reviewdog 59 | base: master 60 | labels: "bump:minor" 61 | -------------------------------------------------------------------------------- /.github/workflows/dockerimage.yml: -------------------------------------------------------------------------------- 1 | name: Docker Image CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | 7 | build: 8 | 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 13 | - name: Build the Docker image 14 | run: docker build --file Dockerfile --tag action-markdownlint:$(date +%s) . 15 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | on: 3 | push: 4 | branches: 5 | - master 6 | tags: 7 | - 'v*.*.*' 8 | pull_request: 9 | types: 10 | - labeled 11 | 12 | jobs: 13 | release: 14 | if: github.event.action != 'labeled' 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 18 | 19 | # Bump version on merging Pull Requests with specific labels. 20 | # (bump:major,bump:minor,bump:patch) 21 | - id: bumpr 22 | if: "!startsWith(github.ref, 'refs/tags/')" 23 | uses: haya14busa/action-bumpr@78ab5a104d20896c9c9122c64221b3aecf1a8cbb # v1.10.0 24 | 25 | # Update corresponding major and minor tag. 26 | # e.g. Update v1 and v1.2 when releasing v1.2.3 27 | - uses: haya14busa/action-update-semver@fb48464b2438ae82cc78237be61afb4f461265a1 # v1.2.1 28 | if: "!steps.bumpr.outputs.skip" 29 | with: 30 | tag: ${{ steps.bumpr.outputs.next_version }} 31 | 32 | # Get tag name. 33 | - id: tag 34 | uses: haya14busa/action-cond@94f77f7a80cd666cb3155084e428254fea4281fd # v1.2.1 35 | with: 36 | cond: "${{ startsWith(github.ref, 'refs/tags/') }}" 37 | if_true: ${{ github.ref }} 38 | if_false: ${{ steps.bumpr.outputs.next_version }} 39 | 40 | # Create release. 41 | - if: "steps.tag.outputs.value != ''" 42 | env: 43 | TAG_NAME: ${{ steps.tag.outputs.value }} 44 | BODY: ${{ steps.bumpr.outputs.message }} 45 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 46 | run: | 47 | gh release create "${TAG_NAME}" -t "Release ${TAG_NAME/refs\/tags\//}" --notes "${BODY}" 48 | 49 | release-check: 50 | if: github.event.action == 'labeled' 51 | runs-on: ubuntu-latest 52 | steps: 53 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 54 | - name: Post bumpr status comment 55 | uses: haya14busa/action-bumpr@78ab5a104d20896c9c9122c64221b3aecf1a8cbb # v1.10.0 56 | -------------------------------------------------------------------------------- /.github/workflows/reviewdog.yml: -------------------------------------------------------------------------------- 1 | name: reviewdog 2 | on: [pull_request] 3 | jobs: 4 | markdownlint: 5 | name: runner / markdownlint 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 9 | - name: markdownlint-github-check 10 | uses: ./ 11 | with: 12 | github_token: ${{ secrets.GITHUB_TOKEN }} 13 | reporter: github-check 14 | level: warning 15 | filter_mode: nofilter 16 | 17 | - name: markdownlint-github-pr-review 18 | uses: ./ 19 | with: 20 | github_token: ${{ secrets.GITHUB_TOKEN }} 21 | reporter: github-pr-review 22 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:20-bullseye-slim 2 | 3 | ENV MARKDOWNLINT_CLI_VERSION=v0.41.0 4 | 5 | RUN npm install -g "markdownlint-cli@$MARKDOWNLINT_CLI_VERSION" 6 | 7 | ENV REVIEWDOG_VERSION=v0.20.2 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends \ 11 | ca-certificates \ 12 | git \ 13 | wget \ 14 | && apt-get clean \ 15 | && rm -rf /var/lib/apt/lists/* 16 | RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/fd59714416d6d9a1c0692d872e38e7f8448df4fc/install.sh \ 17 | | sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} 18 | 19 | COPY entrypoint.sh /entrypoint.sh 20 | 21 | ENTRYPOINT ["/entrypoint.sh"] 22 | CMD [] 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 James Mills / prologic 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub Action: Run markdownlint with reviewdog 2 | 3 | Based on [reviewdog/action-shellcheck](https://github.com/reviewdog/action-shellcheck) 4 | 5 | [![Docker Image CI](https://github.com/prologic/action-markdownlint/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/prologic/action-markdownlint/actions) 6 | [![Release](https://img.shields.io/github/release/prologic/action-markdownlint.svg?maxAge=43200)](https://github.com/prologic/action-markdownlint/releases) 7 | 8 | This action runs [markdownlint](https://github.com/DavidAnson/markdownlint) with 9 | [reviewdog](https://github.com/reviewdog/reviewdog) on pull requests to improve 10 | code review experience. 11 | 12 | ## Inputs 13 | 14 | 15 | ```yml 16 | inputs: 17 | github_token: 18 | description: 'GITHUB_TOKEN.' 19 | default: '${{ github.token }}' 20 | ### Flags for reviewdog ### 21 | level: 22 | description: 'Report level for reviewdog [info,warning,error]' 23 | default: 'error' 24 | reporter: 25 | description: 'Reporter of reviewdog command [github-check,github-pr-review].' 26 | default: 'github-check' 27 | filter_mode: 28 | description: | 29 | Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. 30 | Default is added. 31 | default: 'added' 32 | fail_level: 33 | description: | 34 | If set to `none`, always use exit code 0 for reviewdog. 35 | Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. 36 | Possible values: [none,any,info,warning,error] 37 | Default is `none`. 38 | default: 'none' 39 | fail_on_error: 40 | description: | 41 | Deprecated, use `fail_level` instead. 42 | Exit code for reviewdog when errors are found [true,false] 43 | Default is `false`. 44 | deprecationMessage: Deprecated, use `fail_level` instead. 45 | default: 'false' 46 | reviewdog_flags: 47 | description: 'Additional reviewdog flags' 48 | default: '' 49 | ### Flags for markdownlint-cli ### 50 | markdownlint_flags: 51 | description: "Options of markdownlint-cli command. Default: '.'" 52 | default: '.' 53 | ``` 54 | 55 | 56 | ## Example usage 57 | 58 | ### [.github/workflows/reviewdog.yml](.github/workflows/reviewdog.yml) 59 | 60 | ```yml 61 | name: reviewdog 62 | on: [pull_request] 63 | jobs: 64 | markdownlint: 65 | name: runner / markdownlint 66 | runs-on: ubuntu-latest 67 | steps: 68 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 69 | - name: markdownlint 70 | uses: reviewdog/action-markdownlint@3667398db9118d7e78f7a63d10e26ce454ba5f58 # v0.26.2 71 | with: 72 | github_token: ${{ secrets.GITHUB_TOKEN }} 73 | reporter: github-pr-review 74 | ``` 75 | -------------------------------------------------------------------------------- /_testdata/test.md: -------------------------------------------------------------------------------- 1 | # test_markdownlint 2 | 3 | 4 | ## # blub 5 | * abc 6 | * abc 7 | 1. b 8 | 9 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Run markdownlint with reviewdog' 2 | description: '🐶 Run markdownlint with reviewdog on pull requests to improve code review experience.' 3 | author: 'prologic' 4 | inputs: 5 | github_token: 6 | description: 'GITHUB_TOKEN.' 7 | default: '${{ github.token }}' 8 | ### Flags for reviewdog ### 9 | level: 10 | description: 'Report level for reviewdog [info,warning,error]' 11 | default: 'error' 12 | reporter: 13 | description: 'Reporter of reviewdog command [github-check,github-pr-review].' 14 | default: 'github-check' 15 | filter_mode: 16 | description: | 17 | Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. 18 | Default is added. 19 | default: 'added' 20 | fail_level: 21 | description: | 22 | If set to `none`, always use exit code 0 for reviewdog. 23 | Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. 24 | Possible values: [none,any,info,warning,error] 25 | Default is `none`. 26 | default: 'none' 27 | fail_on_error: 28 | description: | 29 | Deprecated, use `fail_level` instead. 30 | Exit code for reviewdog when errors are found [true,false] 31 | Default is `false`. 32 | deprecationMessage: Deprecated, use `fail_level` instead. 33 | default: 'false' 34 | reviewdog_flags: 35 | description: 'Additional reviewdog flags' 36 | default: '' 37 | ### Flags for markdownlint-cli ### 38 | markdownlint_flags: 39 | description: "Options of markdownlint-cli command. Default: '.'" 40 | default: '.' 41 | runs: 42 | using: 'docker' 43 | image: 'Dockerfile' 44 | branding: 45 | icon: 'zoom-in' 46 | color: 'purple' 47 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd "${GITHUB_WORKSPACE}" || exit 1 4 | git config --global --add safe.directory "${GITHUB_WORKSPACE}" || exit 1 5 | 6 | export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" 7 | 8 | # shellcheck disable=SC2086 9 | markdownlint ${INPUT_MARKDOWNLINT_FLAGS:-.} 2>&1 \ 10 | | reviewdog \ 11 | -efm="%f:%l:%c %m" \ 12 | -efm="%f:%l %m" \ 13 | -name="markdownlint" \ 14 | -reporter="${INPUT_REPORTER:-github-pr-check}" \ 15 | -filter-mode="${INPUT_FILTER_MODE}" \ 16 | -fail-level="${INPUT_FAIL_LEVEL}" \ 17 | -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ 18 | -level="${INPUT_LEVEL}" \ 19 | ${INPUT_REVIEWDOG_FLAGS} || EXIT_CODE=$? 20 | 21 | # github-pr-review only diff adding 22 | if [ "${INPUT_REPORTER}" = "github-pr-review" ]; then 23 | # fix 24 | markdownlint --fix ${INPUT_MARKDOWNLINT_FLAGS:-.} 2>&1 || true 25 | 26 | TMPFILE=$(mktemp) 27 | git diff > "${TMPFILE}" 28 | 29 | git stash -u 30 | 31 | # shellcheck disable=SC2086 32 | reviewdog \ 33 | -f=diff \ 34 | -f.diff.strip=1 \ 35 | -name="markdownlint-fix" \ 36 | -reporter="github-pr-review" \ 37 | -filter-mode="diff_context" \ 38 | -level="${INPUT_LEVEL}" \ 39 | ${INPUT_REVIEWDOG_FLAGS} < "${TMPFILE}" 40 | 41 | git stash drop || true 42 | fi 43 | 44 | exit ${EXIT_CODE} 45 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | --------------------------------------------------------------------------------