This action runs shellcheck with reviewdog on pull requests to improve code review experience.
Optional. ${{ github.token }}
is used by default.
Optional. Report level for reviewdog [info,warning,error].
It's same as -level
flag of reviewdog.
Reporter of reviewdog command [github-pr-check,github-pr-review,github-check]. Default is github-pr-check. github-pr-review can use Markdown and add a link to rule page in reviewdog reports.
Optional. Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
Default is file
.
Optional. 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.
Possible values: [none
, any
, info
, warning
, error
]
Default is none
.
Deprecated, use fail_level
instead.
Optional. Exit code for reviewdog when errors are found [true,false]
Default is false
.
Optional. Additional reviewdog flags
Optional. Base directory to run shellcheck. Same as [path]
of find
command. Default: .
Directories are separated by lines. e.g.:
path: |
tools
src
Optional. File patterns of target files. Same as -name [pattern]
of find
command. Default: *.sh
Patterns are separated by lines. e.g.:
pattern: |
*.bash
*.sh
Optional. Exclude patterns of target files. Same as -not -path [exclude]
of find
command. Default: */.git/*
Patterns are separated by lines. e.g.:
exclude: |
*/.git/*
./.cache/*
Optional. Checks all files with shebangs in the repository even if they do not match pattern
.
Default is false
.
Optional. Flags of shellcheck command. Default: --external-sources
name: reviewdog
on: [pull_request]
jobs:
shellcheck:
name: runner / shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: shellcheck
uses: reviewdog/action-shellcheck@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review # Change reporter.
path: "." # Optional.
pattern: "*.sh" # Optional.
exclude: "./.git/*" # Optional.
check_all_files_with_shebangs: "false" # Optional.
Running shellcheck.exe
on Windows might fail with the following error:
SC1017: Literal carriage return. Run script through tr -d '\r'
This is due to the presence of a carriage return character (\r
) in the script.
To fix this, you can simply create or edit the .gitattributes
file in the root of your repository with the following contents:
*.sh text eol=lf
This would ensure that the scripts are checked out with the correct line ending.