├── .github ├── renovate.json └── workflows │ ├── depup.yml │ ├── dockerimage.yml │ ├── release.yml │ ├── reviewdog.yml │ └── test.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── action.yml ├── entrypoint.sh └── testdata ├── subdir └── text.md └── text.md /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "labels": [ 6 | "bump:patch" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.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: reviewdog/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 | 31 | This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup). 32 | branch: depup/reviewdog 33 | base: master 34 | labels: "bump:minor" 35 | -------------------------------------------------------------------------------- /.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 | BODY: ${{ steps.bumpr.outputs.message }} 45 | # This token is provided by Actions, you do not need to create your own token 46 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 47 | run: | 48 | gh release create "${TAG_NAME}" -t "Release ${TAG_NAME/refs\/tags\//}" --notes "${BODY}" 49 | 50 | release-check: 51 | if: github.event.action == 'labeled' 52 | runs-on: ubuntu-latest 53 | steps: 54 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 55 | - name: Post bumpr status comment 56 | uses: haya14busa/action-bumpr@78ab5a104d20896c9c9122c64221b3aecf1a8cbb # v1.10.0 57 | -------------------------------------------------------------------------------- /.github/workflows/reviewdog.yml: -------------------------------------------------------------------------------- 1 | name: reviewdog 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | jobs: 8 | shellcheck: 9 | name: runner / shellcheck 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 13 | - uses: haya14busa/action-cond@94f77f7a80cd666cb3155084e428254fea4281fd # v1.2.1 14 | id: reporter 15 | with: 16 | cond: ${{ github.event_name == 'pull_request' }} 17 | if_true: "github-pr-review" 18 | if_false: "github-check" 19 | - uses: reviewdog/action-shellcheck@57079a832290a049f49cee90984b072c870fb7d4 # v1.29.3 20 | with: 21 | github_token: ${{ secrets.github_token }} 22 | reporter: ${{ steps.reporter.outputs.value }} 23 | level: warning 24 | 25 | hadolint: 26 | name: runner / hadolint 27 | runs-on: ubuntu-latest 28 | steps: 29 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 30 | - uses: haya14busa/action-cond@94f77f7a80cd666cb3155084e428254fea4281fd # v1.2.1 31 | id: reporter 32 | with: 33 | cond: ${{ github.event_name == 'pull_request' }} 34 | if_true: "github-pr-review" 35 | if_false: "github-check" 36 | - uses: reviewdog/action-hadolint@fc7ee4a9f71e521bc43e370819247b70e5327540 # v1.50.2 37 | with: 38 | github_token: ${{ secrets.github_token }} 39 | reporter: ${{ steps.reporter.outputs.value }} 40 | level: warning 41 | 42 | misspell: 43 | name: runner / misspell 44 | runs-on: ubuntu-latest 45 | steps: 46 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 47 | - uses: reviewdog/action-misspell@9daa94af4357dddb6fd3775de806bc0a8e98d3e4 # v1.26.3 48 | with: 49 | github_token: ${{ secrets.github_token }} 50 | reporter: github-check 51 | level: warning 52 | locale: "US" 53 | 54 | alex: 55 | name: runner / alex 56 | runs-on: ubuntu-latest 57 | steps: 58 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 59 | - uses: reviewdog/action-alex@d6230365b9cb2b2d515f85a1713aca7d11862f60 # v1.15.4 60 | with: 61 | github_token: ${{ secrets.github_token }} 62 | reporter: github-check 63 | level: warning 64 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | jobs: 8 | test-check: 9 | name: runner / (github-check) 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 13 | - uses: ./ 14 | with: 15 | github_token: ${{ secrets.github_token }} 16 | reporter: github-check 17 | level: info 18 | locale: "US" 19 | 20 | test-pr-check: 21 | if: github.event_name == 'pull_request' 22 | name: runner / (github-pr-check) 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 26 | - uses: ./ 27 | with: 28 | github_token: ${{ secrets.github_token }} 29 | reporter: github-pr-check 30 | level: warning 31 | locale: "US" 32 | workdir: ./testdata/subdir/ 33 | 34 | test-pr-review: 35 | if: github.event_name == 'pull_request' 36 | name: runner / (github-pr-review) 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 40 | - uses: ./ 41 | with: 42 | github_token: ${{ secrets.github_token }} 43 | reporter: github-pr-review 44 | level: error 45 | locale: "US" 46 | reviewdog_flags: -filter-mode=file -fail-on-error 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Folders to ignore 2 | .vscode/ -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.20 2 | 3 | ENV REVIEWDOG_VERSION=v0.20.3 4 | 5 | SHELL ["/bin/ash", "-eo", "pipefail", "-c"] 6 | 7 | # hadolint ignore=DL3006 8 | RUN apk --no-cache add git 9 | 10 | RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/fd59714416d6d9a1c0692d872e38e7f8448df4fc/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} 11 | 12 | # TODO: Install a linter and/or change docker image as you need. 13 | RUN wget -O - -q https://git.io/misspell | sh -s -- -b /usr/local/bin/ 14 | 15 | COPY entrypoint.sh /entrypoint.sh 16 | 17 | ENTRYPOINT ["/entrypoint.sh"] 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 reviewdog developers 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 | # action-template 2 | 3 | 4 | [![Test](https://github.com/reviewdog/action-template/workflows/Test/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3ATest) 5 | [![reviewdog](https://github.com/reviewdog/action-template/workflows/reviewdog/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3Areviewdog) 6 | [![depup](https://github.com/reviewdog/action-template/workflows/depup/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3Adepup) 7 | [![release](https://github.com/reviewdog/action-template/workflows/release/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3Arelease) 8 | [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/reviewdog/action-template?logo=github&sort=semver)](https://github.com/reviewdog/action-template/releases) 9 | [![action-bumpr supported](https://img.shields.io/badge/bumpr-supported-ff69b4?logo=github&link=https://github.com/haya14busa/action-bumpr)](https://github.com/haya14busa/action-bumpr) 10 | 11 | ![github-pr-review demo](https://user-images.githubusercontent.com/3797062/73162963-4b8e2b00-4132-11ea-9a3f-f9c6f624c79f.png) 12 | ![github-pr-check demo](https://user-images.githubusercontent.com/3797062/73163032-70829e00-4132-11ea-8481-f213a37db354.png) 13 | 14 | This is a template repository for [reviewdog](https://github.com/reviewdog/reviewdog) action with release automation. 15 | Click `Use this template` button to create your reviewdog action :dog:! 16 | 17 | If you want to create your own reviewdog action from scratch without using this 18 | template, please check and copy release automation flow. 19 | It's important to manage release workflow and sync reviewdog version for all 20 | reviewdog actions. 21 | 22 | This repo contains a sample action to run [misspell](https://github.com/client9/misspell). 23 | 24 | ## Input 25 | 26 | 27 | ```yaml 28 | inputs: 29 | github_token: 30 | description: 'GITHUB_TOKEN' 31 | default: '${{ github.token }}' 32 | workdir: 33 | description: 'Working directory relative to the root directory.' 34 | default: '.' 35 | ### Flags for reviewdog ### 36 | level: 37 | description: 'Report level for reviewdog [info,warning,error]' 38 | default: 'error' 39 | reporter: 40 | description: 'Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].' 41 | default: 'github-pr-check' 42 | filter_mode: 43 | description: | 44 | Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. 45 | Default is added. 46 | default: 'added' 47 | fail_level: 48 | description: | 49 | If set to `none`, always use exit code 0 for reviewdog. Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. 50 | Possible values: [none,any,info,warning,error] 51 | Default is `none`. 52 | default: 'none' 53 | reviewdog_flags: 54 | description: 'Additional reviewdog flags' 55 | default: '' 56 | ### Flags for ### 57 | locale: 58 | description: '-locale flag of misspell. (US/UK)' 59 | default: '' 60 | ``` 61 | 62 | ## Usage 63 | 64 | 65 | ```yaml 66 | name: reviewdog 67 | on: [pull_request] 68 | jobs: 69 | # TODO: change `linter_name`. 70 | linter_name: 71 | name: runner / 72 | runs-on: ubuntu-latest 73 | steps: 74 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 75 | - uses: reviewdog/action-template@c0a1d65401d8e3c97336c75bb4b6f85677e8f27f # v1.20.0 76 | with: 77 | github_token: ${{ secrets.github_token }} 78 | # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. 79 | reporter: github-pr-review 80 | # Change reporter level if you need. 81 | # GitHub Status Check won't become failure with warning. 82 | level: warning 83 | ``` 84 | 85 | ## Development 86 | 87 | ### Release 88 | 89 | #### [haya14busa/action-bumpr](https://github.com/haya14busa/action-bumpr) 90 | You can bump version on merging Pull Requests with specific labels (bump:major,bump:minor,bump:patch). 91 | Pushing tag manually by yourself also work. 92 | 93 | #### [haya14busa/action-update-semver](https://github.com/haya14busa/action-update-semver) 94 | 95 | This action updates major/minor release tags on a tag push. e.g. Update v1 and v1.2 tag when released v1.2.3. 96 | ref: https://help.github.com/en/articles/about-actions#versioning-your-action 97 | 98 | ### Lint - reviewdog integration 99 | 100 | This reviewdog action template itself is integrated with reviewdog to run lints 101 | which is useful for Docker container based actions. 102 | 103 | ![reviewdog integration](https://user-images.githubusercontent.com/3797062/72735107-7fbb9600-3bde-11ea-8087-12af76e7ee6f.png) 104 | 105 | Supported linters: 106 | 107 | - [reviewdog/action-shellcheck](https://github.com/reviewdog/action-shellcheck) 108 | - [reviewdog/action-hadolint](https://github.com/reviewdog/action-hadolint) 109 | - [reviewdog/action-misspell](https://github.com/reviewdog/action-misspell) 110 | 111 | ### Dependencies Update Automation 112 | This repository uses [reviewdog/action-depup](https://github.com/reviewdog/action-depup) to update 113 | reviewdog version. 114 | 115 | [![reviewdog depup demo](https://user-images.githubusercontent.com/3797062/73154254-170e7500-411a-11ea-8211-912e9de7c936.png)](https://github.com/reviewdog/action-template/pull/6) 116 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'TODO: Run with reviewdog' 2 | description: 'TODO: 🐶 Run with reviewdog on pull requests to improve code review experience.' 3 | author: 'TODO: ' 4 | inputs: 5 | github_token: 6 | description: 'GITHUB_TOKEN' 7 | default: '${{ github.token }}' 8 | workdir: 9 | description: 'Working directory relative to the root directory.' 10 | default: '.' 11 | ### Flags for reviewdog ### 12 | level: 13 | description: 'Report level for reviewdog [info,warning,error]' 14 | default: 'error' 15 | reporter: 16 | description: 'Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].' 17 | default: 'github-pr-check' 18 | filter_mode: 19 | description: | 20 | Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. 21 | Default is added. 22 | default: 'added' 23 | fail_level: 24 | description: | 25 | If set to `none`, always use exit code 0 for reviewdog. 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 | reviewdog_flags: 30 | description: 'Additional reviewdog flags' 31 | default: '' 32 | ### Flags for ### 33 | locale: 34 | description: '-locale flag of misspell. (US/UK)' 35 | default: '' 36 | runs: 37 | using: 'docker' 38 | image: 'Dockerfile' 39 | 40 | # Ref: https://haya14busa.github.io/github-action-brandings/ 41 | # TODO: update branding if you want. 42 | branding: 43 | icon: 'check' 44 | color: 'blue' 45 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | if [ -n "${GITHUB_WORKSPACE}" ] ; then 5 | cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 6 | git config --global --add safe.directory "${GITHUB_WORKSPACE}" || exit 1 7 | fi 8 | 9 | export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" 10 | 11 | misspell -locale="${INPUT_LOCALE}" . \ 12 | | reviewdog -efm="%f:%l:%c: %m" \ 13 | -name="linter-name (misspell)" \ 14 | -reporter="${INPUT_REPORTER:-github-pr-check}" \ 15 | -filter-mode="${INPUT_FILTER_MODE}" \ 16 | -fail-level="${INPUT_FAIL_LEVEL}" \ 17 | -level="${INPUT_LEVEL}" \ 18 | ${INPUT_REVIEWDOG_FLAGS} 19 | -------------------------------------------------------------------------------- /testdata/subdir/text.md: -------------------------------------------------------------------------------- 1 | Determinisitic result is important! 2 | 3 | -------------------------------------------------------------------------------- /testdata/text.md: -------------------------------------------------------------------------------- 1 | Determinisitic result is important. 2 | 3 | colour # <= Check -locale 4 | 5 | langauge 6 | --------------------------------------------------------------------------------