Skip to content
Latchkey

How to Lint Shell Scripts With ShellCheck in GitHub Actions

ShellCheck flags quoting, portability, and logic bugs in shell scripts, and it ships preinstalled on Ubuntu runners.

Run shellcheck over your scripts in a CI step. It is already on GitHub-hosted Ubuntu runners, so you can gate merges on clean shell scripts with no install step.

Steps

  • Point shellcheck at your script files or a scripts directory.
  • Fail the job on any finding so problems block the merge.
  • Add inline # shellcheck disable=SCxxxx comments for justified exceptions.

Workflow

.github/workflows/ci.yml
jobs:
  shellcheck:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: shellcheck scripts/*.sh

Gotchas

  • ShellCheck needs a shebang or -s bash to know the dialect; add one or pass the shell explicitly.
  • Use find . -name "*.sh" -print0 | xargs -0 shellcheck to cover nested directories.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →