├── .github ├── renovate.json └── workflows │ ├── depup.yml │ ├── dockerimage.yml │ ├── release.yml │ └── reviewdog.yml ├── .yamllint.yaml ├── Dockerfile ├── LICENSE ├── README.md ├── action.yml ├── entrypoint.sh └── testdata └── test.yaml /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "rangeStrategy": "replace" 6 | } 7 | -------------------------------------------------------------------------------- /.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 | reviewdog: 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: REVIEWDOG_VERSION 19 | repo: reviewdog/reviewdog 20 | 21 | - name: Create Pull Request 22 | uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 23 | with: 24 | token: ${{ secrets.GITHUB_TOKEN }} 25 | title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 26 | commit-message: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 27 | body: | 28 | Update reviewdog to [v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/releases/tag/v${{ steps.depup.outputs.latest }}) 29 | 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 }}) 30 | This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup). 31 | branch: depup/reviewdog 32 | base: master 33 | labels: "bump:minor" 34 | -------------------------------------------------------------------------------- /.github/workflows/dockerimage.yml: -------------------------------------------------------------------------------- 1 | name: Docker Image CI 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 12 | - name: Build the Docker image 13 | run: docker build . --file Dockerfile --tag ${{ github.repository }}:$(date +%s) 14 | -------------------------------------------------------------------------------- /.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 | CURRENT: ${{ steps.bumpr.outputs.current_version }} 45 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 46 | run: | 47 | gh release create "${TAG_NAME}" -t "Release ${TAG_NAME/refs\/tags\//}" --generate-notes --notes-start-tag "${CURRENT}" 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 | yamllint: 5 | name: runner / yamllint 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 9 | - name: yamllint-github-pr-check 10 | uses: ./ 11 | with: 12 | github_token: ${{ secrets.github_token }} 13 | reporter: github-pr-check 14 | yamllint_flags: "testdata/" 15 | - name: yamllint-github-check 16 | uses: ./ 17 | with: 18 | github_token: ${{ secrets.github_token }} 19 | reporter: github-check 20 | level: warning 21 | yamllint_flags: "testdata/" 22 | - name: yamllint-github-pr-review 23 | uses: ./ 24 | with: 25 | github_token: ${{ secrets.github_token }} 26 | reporter: github-pr-review 27 | yamllint_flags: "testdata/" 28 | -------------------------------------------------------------------------------- /.yamllint.yaml: -------------------------------------------------------------------------------- 1 | extends: default 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:alpine 2 | 3 | ENV REVIEWDOG_VERSION=v0.20.3 4 | 5 | RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/fd59714416d6d9a1c0692d872e38e7f8448df4fc/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} 6 | RUN apk --no-cache add git 7 | 8 | RUN pip install "pyyaml<=5.3.1" "yamllint" 9 | 10 | COPY entrypoint.sh /entrypoint.sh 11 | 12 | ENTRYPOINT ["/entrypoint.sh"] 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 haya14busa 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 yamllint with reviewdog 2 | 3 | [![Docker Image CI](https://github.com/reviewdog/action-yamllint/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/reviewdog/action-yamllint/actions) 4 | [![Release](https://img.shields.io/github/release/reviewdog/action-yamllint.svg?maxAge=43200)](https://github.com/reviewdog/action-yamllint/releases) 5 | 6 | This action runs [yamllint](https://github.com/adrienverge/yamllint) with 7 | [reviewdog](https://github.com/reviewdog/reviewdog) on pull requests to improve 8 | code review experience. 9 | 10 | [![github-pr-check sample](https://user-images.githubusercontent.com/8191198/72208542-0ddba200-34a4-11ea-90ce-c9508942420c.png)](https://github.com/reviewdog/action-yamllint/pull/1) 11 | [![github-pr-review sample](https://user-images.githubusercontent.com/8191198/72208536-087e5780-34a4-11ea-8ac7-bc7161c9cc20.png)](https://github.com/reviewdog/action-yamllint/pull/1) 12 | 13 | ## Inputs 14 | 15 | ### `github_token` 16 | 17 | Optional. `${{ github.token }}` is used by default. 18 | 19 | ### `level` 20 | 21 | Optional. Report level for reviewdog [info,warning,error]. 22 | It's same as `-level` flag of reviewdog. 23 | 24 | ### `reporter` 25 | 26 | Reporter of reviewdog command [github-pr-check,github-check,github-pr-review]. 27 | Default is github-pr-check. 28 | It's same as `-reporter` flag of reviewdog. 29 | 30 | github-pr-review can use Markdown and add a link to rule page in reviewdog reports. 31 | 32 | ### `filter_mode` 33 | 34 | Optional. Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. Default is added. 35 | 36 | ### `fail_level` 37 | 38 | Optional. If set to `none`, always use exit code 0 for reviewdog. 39 | Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. 40 | Possible values: [`none`, `any`, `info`, `warning`, `error`] 41 | Default is `none`. 42 | 43 | ### `fail_on_error` 44 | 45 | Deprecated, use `fail_level` instead. 46 | Optional. Exit code for reviewdog when errors are found [true,false] Default is `false`. 47 | 48 | ### `reviewdog_flags` 49 | 50 | Optional. Additional reviewdog flags. 51 | 52 | ### `yamllint_flags` 53 | 54 | Optional. Flags and args of yamllint command. Default: '.' 55 | 56 | ## Example usage 57 | 58 | You can create [yamllint 59 | config](https://yamllint.readthedocs.io/en/stable/configuration.html) 60 | and this action uses that config too. 61 | 62 | ### [.github/workflows/reviewdog.yml](.github/workflows/reviewdog.yml) 63 | 64 | ```yml 65 | name: reviewdog 66 | on: [pull_request] 67 | jobs: 68 | yamllint: 69 | name: runner / yamllint 70 | runs-on: ubuntu-latest 71 | steps: 72 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 73 | - name: yamllint 74 | uses: reviewdog/action-yamllint@f01d8a48fd8d89f89895499fca2cff09f9e9e8c0 # v1.21.0 75 | with: 76 | github_token: ${{ secrets.github_token }} 77 | reporter: github-pr-review # Change reporter. 78 | yamllint_flags: 'src/' 79 | ``` 80 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "Run yamllint with reviewdog" 2 | description: "🐶 Run yamllint with reviewdog on pull requests to improve code review experience." 3 | author: "aslafy-z" 4 | inputs: 5 | github_token: 6 | description: "GITHUB_TOKEN." 7 | default: "${{ github.token }}" 8 | level: 9 | description: "Report level for reviewdog [info,warning,error]" 10 | default: "error" 11 | reporter: 12 | description: | 13 | Reporter of reviewdog command [github-pr-check,github-pr-review,github-check]. 14 | Default is github-pr-check. 15 | github-pr-review can use Markdown and add a link to rule page in reviewdog reports. 16 | default: "github-pr-check" 17 | filter_mode: 18 | description: | 19 | Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. 20 | Default is added. 21 | default: "added" 22 | fail_level: 23 | description: | 24 | If set to `none`, always use exit code 0 for reviewdog. 25 | Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. 26 | Possible values: [none,any,info,warning,error] 27 | Default is `none`. 28 | default: 'none' 29 | fail_on_error: 30 | description: | 31 | Deprecated, use `fail_level` instead. 32 | Exit code for reviewdog when errors are found [true,false] 33 | Default is `false`. 34 | deprecationMessage: Deprecated, use `fail_level` instead. 35 | default: "false" 36 | reviewdog_flags: 37 | description: "Additional reviewdog flags" 38 | default: "" 39 | yamllint_flags: 40 | description: "flags and args of yamllint command. Default: '.'" 41 | default: "." 42 | runs: 43 | using: "docker" 44 | image: "Dockerfile" 45 | branding: 46 | icon: "alert-octagon" 47 | color: "blue" 48 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd "$GITHUB_WORKSPACE" || exit 4 | 5 | git config --global --add safe.directory $GITHUB_WORKSPACE 6 | 7 | export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" 8 | 9 | echo '::group:: Running yamllint with reviewdog 🐶 ...' 10 | yamllint --version 11 | yamllint --format "parsable" ${INPUT_YAMLLINT_FLAGS:-'.'} | 12 | reviewdog \ 13 | -efm="%f:%l:%c: %m" \ 14 | -name "yamllint" \ 15 | -reporter="${INPUT_REPORTER:-github-pr-check}" \ 16 | -level="${INPUT_LEVEL}" \ 17 | -filter-mode="${INPUT_FILTER_MODE}" \ 18 | -fail-level="${INPUT_FAIL_LEVEL}" \ 19 | -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ 20 | ${INPUT_REVIEWDOG_FLAGS} 21 | EXIT_CODE=$? 22 | echo '::endgroup::' 23 | 24 | exit $EXIT_CODE 25 | -------------------------------------------------------------------------------- /testdata/test.yaml: -------------------------------------------------------------------------------- 1 | test: 1 2 | i_am_a_very_much_too_long_line_i_can_swear_you_will_see_one_day: i_am_not_ok_with_this_kind_of_shitty_things 3 | howToSay: | 4 | misaligned: 4 5 | --------------------------------------------------------------------------------