Skip to content
Latchkey

How to Run ShellCheck on Scripts in GitHub Actions

Shell scripts hide quoting and word-splitting bugs that only break in production; ShellCheck finds them in CI.

Run ShellCheck against every tracked .sh file so warnings and errors fail the job.

Steps

  • Collect the shell scripts to lint (a glob or git ls-files).
  • Run shellcheck against them, optionally with -S error to gate only on errors at first.
  • Fix or annotate findings; tighten the severity over time.

Workflow

.github/workflows/shellcheck.yml
name: ShellCheck
on: [pull_request]
jobs:
  shellcheck:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run ShellCheck
        run: |
          mapfile -t files < <(git ls-files '*.sh')
          shellcheck "${files[@]}"

Notes

  • ShellCheck ships preinstalled on GitHub-hosted Ubuntu images, so no install step is needed.
  • On Latchkey managed runners script-lint jobs run cheaper and self-heal if a runner dies.

Related guides

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