Skip to content

Workflow bash ci

github-actions[bot] edited this page Nov 28, 2026 · 7 revisions

bash-ci

What it does. Lints and tests the shell in a repository: shellcheck and shfmt over every tracked script, an optional test command (bats, a runner script), an optional configuration lint (yamllint, ansible-lint), the workflow lint, optional pull-request checks and the same CI green gate. Holds no token in any job.

Why it exists. Every repository carries shell. The nine Python callers alone held 47 scripts that no workflow linted. A repository that is mostly shell names this job ci; one that also calls python-ci names it shell and requires both gates, so the composition rule is one caller job per language.

How it finds scripts

Scripts are found, not listed: every tracked file under paths whose name ends in .sh or .bash, or whose first line is a sh or bash shebang. shellcheck and shfmt are downloaded at a pinned version and checked against a pinned sha256 before they run, so no third-party action joins the Actions allow-list for them and what lints today is what lints next year. The download is cached, and the hash is checked on disk whether it came from the cache or the network.

Jobs and trust boundaries

Every job has contents: read and nothing else, because a lint needs nothing: shellcheck, shfmt, test (a matrix over runners), distro (the suite inside other distributions' images), config-lint, workflow-lint, fragment-check, commit-claims and ci-green. The test job and, in arduino-ci, its host test job keep sudo, because a caller may legitimately write sudo apt-get install -y bats; nothing in the workflow's own steps uses it.

A minimal caller

jobs:
  shell:
    uses: ChiefGyk3D/git-your-ship-together/.github/workflows/bash-ci.yml@<sha> # vX.Y.Z
    permissions:
      contents: read
      pull-requests: read
    with:
      shfmt-args: -i 2 -ci
      test-command: ./tests/run.sh
      workflow-lint: false   # python-ci already lints the workflow files
      egress-policy: block

Notes: four-space indent is the default because seven of nine callers write it; two pass -i 2 -ci. A shell-only repository also sets codeql-languages: actions and pip-audit-requirements: "" on security. The distro job's egress list, its Kali and Parrot pinning and the Fedora caveat are described on the python-ci page.

Inputs (37), read from bash-ci.yml:

Input Type Default Meaning
paths string . Space-separated git pathspecs to search for scripts; :!dir excludes one.
shellcheck-version string 0.11.0 shellcheck release to download (koalaman/shellcheck), without the v.
shellcheck-sha256 string 8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198 SHA-256 of the shellcheck linux.x86_64 tarball for that version.
shellcheck-severity string warning Lowest severity that fails the job - error, warning, info or style.
shellcheck-args string -x Extra shellcheck arguments, e.g. -x to follow sourced files or -e SC2034.
shellcheck-continue-on-error boolean false Report shellcheck findings without failing the job. A migration aid, not a resting state.
shfmt boolean true Run shfmt and fail on a formatting diff.
shfmt-version string 3.14.1 shfmt release to download (mvdan/sh), without the v.
shfmt-sha256 string 76e77641faa025814b77f153b29796b8e6fa2fca03e0c76a691608b86c7ea7bf SHA-256 of the shfmt linux_amd64 binary for that version.
shfmt-args string -i 4 -ci shfmt style arguments. The default is what most of the calling repositories already write; Skid-Finder and Hammunition pass -i 2 -ci.
shfmt-continue-on-error boolean false Report a formatting diff without failing the job. A migration aid, not a resting state.
test-install-command string empty Shell run before the tests, e.g. sudo apt-get install -y bats; empty installs nothing.
skip-docs-only boolean false Leave the test and distro jobs out of a pull request that changes only documentation, with no per-repository edit beyond setting this. Off by default: a workflow cannot read whether its repository is private (a policy test forbids it), so the caller opts in. A new classify job reads the pull request's changed files from the API (never from the checkout) and says docs-only only when every path matches docs-only-patterns and none is under .github/ or never-skip-patterns; every doubt runs the tests. Lint, workflow lint, type check and the security scans are never skipped, and CI green still fails on any failed job. The job holds contents: read and pull-requests: read; every caller grants both, since a reusable job cannot exceed the caller's grant. The second read lets it read the file list; without it the classifier fails closed and every job runs.
docs-only-patterns string *.md docs/**/*.md Newline-separated globs, anchored at the repository root (* stops at /, ** crosses it), for the paths that make the tests unnecessary. The default is markdown only. A pattern that matches every path is refused. Used with skip-docs-only.
never-skip-patterns string empty Newline-separated globs that always run every job, on top of .github/**. Use it for a markdown file your tests read. Used with skip-docs-only.
test-command string empty The shell test suite, e.g. bats tests/ or ./tests/run.sh; empty skips the job.
config-lint-install-command string pip install yamllint Installs the configuration linters for config-lint-command, with Python available.
config-lint-command string empty Lints the configuration kept beside the scripts, e.g. yamllint . or ansible-lint; empty skips the job.
config-lint-python-version string 3.13 Python for the configuration lint job.
fragment-check-command string empty Shell run on pull requests only, with the full history checked out and BASE set to the pull request's base branch name (so origin/$BASE resolves); empty skips the Changelog fragment job. For a repository that keeps one changelog fragment per change under changelog.d/, e.g. python3 scripts/changelog.py check-pr --base "origin/$BASE". Part of the gate when set.
commit-claims-command string empty Shell run on pull requests only, with the full history checked out, BASE set to the base branch name and HEAD to the pull request's head commit; empty skips the Commit claims job. For a repository that checks what each commit message claims against its diff, e.g. python3 scripts/check_commit_claims.py --range "origin/$BASE..HEAD". Part of the gate when set.
workflow-lint boolean true Run actionlint and zizmor over the caller's own workflow files. Turn off on one caller job when another already runs it.
zizmor-persona string regular zizmor strictness - regular, pedantic or auditor.
runners string ["ubuntu-24.04"] JSON array of runner labels for the test job, e.g. ["ubuntu-24.04", "ubuntu-24.04-arm", "macos-15"]. test-install-command and test-command run under bash on each.
distros string [] JSON array of container images to run the tests in as well, e.g. ["debian:13", "kalilinux/kali-rolling"]. GitHub-hosted runners are Ubuntu, macOS and Windows only; another distribution is tested inside its official image on a runner. [] skips the job.
distro-runners string ["ubuntu-24.04"] JSON array of runner labels the distros run on. Add ubuntu-24.04-arm to run the images natively on arm64.
distro-setup-command string export DEBIAN_FRONTEND=noninteractive if command -v apt-get >/dev/null 2>&1; then # Kali's redirector hands out a different mirror per request, which # no egress list can follow; the CDN host it fronts is one name. if grep -qx 'ID=kali' /etc/os-release; then sed -i 's|http://http.kali.org|http://kali.download|g' /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources 2>/dev/null || true fi # Parrot's package redirector (director.parrot.sh) does the same; # its /direct path serves the pool from deb.parrot.sh itself. if grep -qx 'ID=parrot' /etc/os-release; then sed -i 's|https://deb.parrot.sh/parrot|https://deb.parrot.sh/direct/parrot|g' /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources 2>/dev/null || true fi # A mirror that answers 502, or is caught mid-sync (Kali's "File has # unexpected size", #228), is not retried by apt itself, so the whole # step is tried six times with a growing pause (20 s up to 60 s). The # package lists are cleared between tries so a partial index is never # reused; the last failure exits non-zero with apt's own error shown. for attempt in 1 2 3 4 5 6; do apt-get -o Acquire::Retries=3 update -qq && apt-get -o Acquire::Retries=3 install -y -qq --no-install-recommends bash git ca-certificates && break if [ "$attempt" = 6 ]; then echo "apt-get still failing after 6 attempts" >&2 exit 1 fi rm -rf /var/lib/apt/lists/* sleep $((attempt * 20 > 60 ? 60 : attempt * 20)) done elif command -v dnf >/dev/null 2>&1; then dnf install -y -q bash git ca-certificates fi Shell run as root inside each image before test-install-command. The default installs bash, git and ca-certificates with apt-get where it exists, else with dnf; non-interactive and quiet.
distro-egress-policy string block harden-runner egress policy for the distro job - audit logs outbound connections, block allows only distro-allowed-endpoints and extra-allowed-endpoints.
distro-allowed-endpoints string archive.ubuntu.com:80 auth.docker.io:443 deb.debian.org:80 deb.parrot.sh:443 docker-images-prod.s3.dualstack.us-east-1.amazonaws.com:443 kali.download:80 ports.ubuntu.com:80 production.cloudfront.docker.com:443 registry-1.docker.io:443 security.ubuntu.com:80 harden-runner allow-list for the distro job in block, space-separated host:port entries. The default is Docker Hub's image pull (registry, auth, CDN and the S3 host layer blobs redirect to), the package mirrors of the Debian, Ubuntu, Kali and Parrot images. A distribution not named here (Fedora, whose metalink mirrors vary by run) needs its hosts in extra-allowed-endpoints, or distro-egress-policy set to audit. Wildcards are not supported and a newline-separated list matches nothing.
distro-continue-on-error boolean false Let a failing distro run leave the gate green. For a suite that assumes a non-root user or a newer Python than the distribution ships; the result stays visible on the job.
egress-policy string audit harden-runner egress policy for every job except distro - audit logs outbound connections, block allows only allowed-endpoints. Jobs that hold no secret follow egress-policy-secretless instead (EX-0001).
egress-policy-secretless string block harden-runner egress policy for the jobs that hold no stored secret, no OIDC token and no write-scoped or publish-capable token (read-only contents, a SARIF upload at most), and whose output no privileged job consumes - exactly audit or block. Defaults to block since security exception EX-0001 (GitHub-hosted runners in westus2 broke harden-runner block) was closed on 2026-11-02 after harden-runner v2.22.3 passed on westus2; see docs/security/exceptions/. Every job still has the default read-only job token. Set audit to opt out if the defect recurs. Any other job follows egress-policy. Any other value fails the job.
allowed-endpoints string api.github.com:443 files.pythonhosted.org:443 ghcr.io:443 github.com:443 objects.githubusercontent.com:443 pkg-containers.githubusercontent.com:443 pypi.org:443 raw.githubusercontent.com:443 registry.npmjs.org:443 release-assets.githubusercontent.com:443 harden-runner allow-list for block, space-separated host:port entries. The default is every endpoint this workflow's jobs reach; the runner's own infrastructure needs no entry. Wildcards are not supported and a newline-separated list matches nothing.
extra-allowed-endpoints string empty Appended to allowed-endpoints, for hosts only this repository reaches, such as an apt repository its test install needs. Same format.
timeout-minutes number 10 Per-job timeout.
runs-on string "ubuntu-latest" Runner for every non-matrix job, as a JSON string because runs-on takes a string, an array or an object. The default preserves the label those jobs previously used. The test and distro jobs keep their existing runner matrices.
allow-self-hosted boolean false Let these jobs run on an attested self-hosted runner. The runner must be ephemeral, one job per VM, and isolated from secrets and the network.

Skipping the tests on a docs-only pull request. Set skip-docs-only: true (off by default) and a pull request that changes only *.md or docs/**/*.md leaves the Test and Distro jobs out; lint and the security scans still run, and CI green still fails on any failed job. Every caller grants pull-requests: read in its permissions:, whether or not it sets this input, because a reusable job cannot exceed the caller's grant. The classifier reads the changed files with it. See Docs-only fast path.

Choosing the runner

runs-on is a JSON string that every job reads through fromJSON(inputs.runs-on), because runs-on takes a string, an array or an object: '"ubuntu-latest"' (the default), '["self-hosted","linux"]' or '{"group":"my-group","labels":["linux"]}'. Invalid JSON fails the job at expression time. allow-self-hosted (default false) is the caller's attestation that a self-hosted runner is ephemeral, one job per VM, and isolated from secrets and the network. Without it, a step right after harden-runner in every job fails on any runner that is not GitHub-hosted. With it, a self-hosted runner still takes only push, schedule, workflow_dispatch, release and same-repository pull_request events. The test and distro jobs keep their runner matrices (runners and distro-runners) and ignore runs-on.

What it refuses to do

It never fetches a secret, never gives any job more than contents: read, and never runs an unpinned linter binary.

Clone this wiki locally