https://github.com/luizm/action-sh-checker
A GitHub action that performs static analysis for shell scripts using shellcheck, shfmt and checkbashisms.
https://github.com/luizm/action-sh-checker
checkbashisms github-actions shell-script shellcheck shftm
Last synced: 5 months ago
JSON representation
A GitHub action that performs static analysis for shell scripts using shellcheck, shfmt and checkbashisms.
- Host: GitHub
- URL: https://github.com/luizm/action-sh-checker
- Owner: luizm
- License: mit
- Created: 2019-11-15T15:09:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-23T21:42:43.000Z (over 1 year ago)
- Last Synced: 2025-05-07T10:02:00.955Z (about 1 year ago)
- Topics: checkbashisms, github-actions, shell-script, shellcheck, shftm
- Language: Shell
- Homepage:
- Size: 110 KB
- Stars: 134
- Watchers: 4
- Forks: 13
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sh-checker
[](https://github.com/luizm/action-sh-checker/actions/workflows/ci.yml)
A [GitHub action](https://docs.github.com/en/free-pro-team@latest/actions) that performs static analysis of shell scripts using [shellcheck](https://github.com/koalaman/shellcheck), [shfmt](https://github.com/mvdan/sh) and [checkbashisms](https://linux.die.net/man/1/checkbashisms)

## Usage
Job example to check all sh files but ignore the directory `.terraform` and file `dir/example.sh`
```yaml
name: example
on:
- pull_request
jobs:
sh-checker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run the sh-checker
uses: luizm/action-sh-checker@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHELLCHECK_OPTS: -e SC1004 # exclude some shellcheck warnings.
SHFMT_OPTS: -s # arguments to shfmt.
with:
sh_checker_comment: true
sh_checker_exclude: ".terraform ^dir/example.sh"
```
### Environment Variables
`SHELLCHECK_OPTS`: Used to specify shellcheck arguments.
`SHFMT_OPTS`: Used to specify shfmt arguments.
### Inputs
`sh_checker_only_diff`: (optional) Only check the files that were changed in the pull request. Default is to check all files in the repo.
`sh_checker_exclude`: (optional) Directory or file name that doesn't need to be checked.
`sh_checker_comment`: (optional) If true, it will show the errors as commentaries in the pull requests. Default is false.
`sh_checker_shfmt_disable`: (optional) If true, it will skip shfmt. Default is false.
`sh_checker_shellcheck_disable`: (optional) If true, it will skip shellcheck. Default is false.
`sh_checker_checkbashisms_enable`: (optional) If true, run checkbashisms tool against scripts. Default is false.
### Secrets
`GITHUB_TOKEN`: The GitHub API token used to post comments to pull requests. Required only if `sh_checker_only_diff` or `sh_checker_comment` is set to true.