GitHub Actions linter: validate workflows before you push
Last reviewed: 23 November 2026, against SecureCI CLI 1.4.0
A GitHub Actions linter checks the workflow files in .github/workflows for mistakes before GitHub runs them. A YAML linter only checks that the file is valid YAML and formatted consistently. A workflow linter also checks the workflow syntax, the ${{ }} expressions and the if: conditions. With the free SecureCI CLI (secureci), one command does that on your machine: secureci validate .github/workflows/ci.yml. The same pass reports security findings too.
If you meant running ESLint or another code linter inside a workflow, that is a different task. You add a step that runs your linter, like any other build step. This guide is about checking the workflow files themselves.
Short answer:
- Install:
npm install -g @secureci/cli(Node.js 20+), or the standalone binary. - Lint one file:
secureci validate .github/workflows/ci.yml - Lint every workflow:
secureci validate .github/workflows/*.yml - Lint every pull request:
secureci init workflowwrites a ready-to-commit workflow.
What a workflow linter checks that a YAML linter does not
A workflow file can be perfect YAML and still fail on GitHub. The YAML parser does not know that every job needs a runs-on, or that sucess() is not a function. It cannot tell you that a job-level if: is not allowed to read the matrix context.
A workflow linter reads the file the way GitHub does. secureci validate checks the syntax of workflow and action files. It parses each ${{ }} expression and each if: condition. Then it adds security checks: untrusted input in scripts, token permissions, risky triggers and actions with known advisories.
None of this runs your workflow. The docs describe validate as static syntax, expression, template-injection, trigger and contract checks. To see which jobs and steps would run, use secureci run --dry-run instead, as in our guide to running GitHub Actions locally.
Lint a workflow locally with secureci validate
Install
The SecureCI CLI is free and open source (MIT). Install it from npm, which needs Node.js 20 or later:
npm install -g @secureci/cli
# or run it without installing:
npx @secureci/cli --help
There is also a standalone binary for Linux, macOS and Windows that needs no Node.js. The steps, and how to check the binary against its SHA256SUMS, are in the install section of the docs.
Run it on one file, then on every workflow
Here is a small workflow with several mistakes in it. Two are expression errors. Two are security problems that would let a pull request from a fork run its own code with your secrets. It also has no permissions: block.
# .github/workflows/ci.yml
name: CI
on:
pull_request_target:
jobs:
greet:
runs-on: ubuntu-latest
if: ${{ matrix.os == 'linux' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: echo "Thanks for ${{ github.event.pull_request.title }}"
- if: ${{ sucess() }}
run: npm test
Point validate at the file. This is the real output of CLI 1.4.0. We removed one warning line about the advisory lookup, which was rate-limited on our machine:
$ secureci validate .github/workflows/ci.yml
[INFO] Validating workflow: .github/workflows/ci.yml
[ERROR] Validation failed: .github/workflows/ci.yml
[ERROR] [ERROR] jobs.greet.if: Unrecognized named-value: 'matrix'
[ERROR] [ERROR] jobs.greet.steps[2].if: Unrecognized function: 'sucess'
[ERROR] [ERROR] jobs.greet.steps[1].run: ${{ github.event.pull_request.title }} expands untrusted input (github.event.pull_request.title) into the shell script, so a crafted value can run arbitrary commands. Pass it through env: (e.g. env: TITLE: ${{ github.event.pull_request.title }}) and use "$TITLE" instead.
[WARN] [WARNING] permissions: No top-level permissions: and job(s) "greet" declare none, so their GITHUB_TOKEN gets the repository's default permissions (read/write on every scope in many repositories). Add a top-level block such as "permissions: { contents: read }", or declare permissions on each job
[ERROR] [ERROR] jobs.greet.steps[0]: Job "greet" checks out untrusted code (ref: ${{ github.event.pull_request.head.sha }}) in a workflow triggered by "pull_request_target", then executes it at steps[1] (run:). These triggers run with the repository's secrets and a write token, so a fork can run its own code with them; actions/checkout refuses this checkout by default, so the step fails until someone sets allow-unsafe-pr-checkout: true, which would run the fork's code. Check out the base ref instead, or move the build to an unprivileged pull_request workflow
The command exited with status 1, so a script or a Git hook can stop on it. To lint every workflow in the repository, pass several files. Your shell expands the glob:
secureci validate .github/workflows/*.yml
The advisory lookup calls the GitHub API, which allows 60 anonymous requests an hour. Set GITHUB_TOKEN or GH_TOKEN, or sign in with gh, for a higher limit. Results are cached for 24 hours.
Read the output
Each finding starts with its severity and a path into the file, such as jobs.greet.steps[1].run. Then comes the message, which usually says how to fix it. Errors fail validation. Warnings are reported, but validation still passes.
For scripts and dashboards, ask for JSON. Each finding then has a path, message, severity and rule:
secureci validate .github/workflows/ci.yml --format json
On the workflow above, the two expression errors carry the rule secureci/expression. The others are secureci/injection, secureci/permissions and secureci/dangerous-trigger. These are the same rule ids that SARIF output uses. Both formats exit non-zero when validation fails. The output formats section lists every rule.
Expressions and if: conditions, evaluated as GitHub does
The first two errors above are easy to miss in review. A typo like sucess() looks right at a glance. A job-level if: that reads matrix looks reasonable, but GitHub does not allow it. A job's if: can only use github, needs, vars and inputs.
The SecureCI CLI evaluates expressions and if: conditions the way GitHub does. It follows the same rules about which context is available where, and it rejects an invalid if: the same way. Before anything runs, it catches syntax errors, unknown functions, wrong argument counts and contexts used where GitHub does not allow them. The docs on conditional execution list every context and function it supports.
Because expressions are parsed rather than matched as text, the security checks are more exact too. ${{ contains(github.event.issue.title, 'bug') }} produces a boolean, so it is not flagged as injection. toJSON(github.event) passes untrusted text through, so it is. The result is far fewer false positives than plain pattern matching.
Security checks in the same pass
The same validate run covers four kinds of security finding (since v0.6.0):
- Template injection is an error. Untrusted input, such as a pull request title, expanded into a
run:script or the script ofactions/github-scriptcan run commands. The fix is to pass it throughenv:and quote the variable. See template injection checks. GITHUB_TOKENpermissions are warnings by default: nopermissions:block,write-all, or a write scope at the top level. A contract can make them errors. See token permissions.- Dangerous triggers: a
pull_request_targetorworkflow_runjob that checks out untrusted code and then runs it is an error. The trigger alone is a warning, so you can audit every such workflow. See dangerous triggers. - Known advisories from the GitHub Advisory Database. Critical and high advisories are errors, and medium and low ones are warnings. See known security advisories.
Local composite actions and local reusable workflows are followed, so wrapping a step in a local action does not hide it from the injection check.
Run the linter on every pull request
A linter on your laptop only helps if everyone runs it. To run it on every pull request, let the CLI write the workflow for you:
secureci init workflow
This writes .github/workflows/secureci.yml, which uses the SecureCI GitHub Action. Its actions are pinned to commit SHAs, and the file itself passes secureci validate with no findings. This is the job it wrote with CLI 1.4.0, without its comment lines:
jobs:
secureci:
runs-on: ubuntu-latest
permissions:
contents: read
actions: read # upload-sarif reads the workflow run
security-events: write # upload SARIF to code scanning
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: secure-ci/cli@a8bc54904c21f09b96a80850c557fdaa5f92abb6 # v1.4.0
By default the action validates every file in .github/workflows and uploads a SARIF report, so findings show up on the pull request in GitHub code scanning. The upload needs code scanning enabled for the repository (Settings > Code security). If you cannot enable it, run secureci init workflow --no-upload. The job fails if any workflow is invalid. The GitHub Action docs list every input.
Check workflows against your own standard
Generic rules cannot know that every deploy in your organisation must run a security scan first. A pipeline contract can. It is a short YAML file that requires or forbids actions, fixes their order, sets minimum versions, demands SHA pinning and limits which owners are allowed:
# contracts/platform-standard.yml
required:
- uses: org/security-scan
min-version: v1.2.0
- uses: org/deploy # must run after security-scan
forbidden:
- uses: org/legacy-deploy
pins:
required: true # every remote action pinned to a commit SHA
allowed-owners: [actions, my-org]
secureci validate .github/workflows/deploy.yml --contract contracts/platform-standard.yml
A missing required action, one below its minimum version, the wrong order or a forbidden action is an error. A contract can also make permission findings errors, forbid triggers and set which advisory severity fails. The action takes the same file through its contract input. Details are in pipeline contracts, and SecureCI vs GitHub native security shows how a contract sits next to GitHub's own allowed-actions policy.
Other linters and when to use them
Other tools cover parts of this. Here is what each one checks, next to what secureci validate does.
- A YAML linter only checks that the file is valid YAML and formatted consistently. It will not catch any of the mistakes in the example.
- actionlint is a correctness linter: syntax, expression types, action inputs, and shellcheck on
run:scripts. It has no organisation rules, pinning checks or lockfile. - zizmor runs around 40 security audits, such as template injection and excessive permissions. It cannot require actions, their order or minimum versions.
SecureCI emits SARIF, so its findings can sit next to any of these tools in GitHub code scanning. For the feature-by-feature table, see SecureCI vs actionlint and zizmor.
Limits
- Offline runs use cached advisories only.
--offlinemakes no advisory requests and warns about repositories with nothing cached. - Contracts apply to workflow files only. A contract describes a sequence of jobs and steps, so passing
--contractagainst a standalone action file fails with a clear error. - Remote actions are not inspected by the injection check. Untrusted data that reaches a script indirectly, through a step output or an
env:value, is not tracked either. - Dangerous-trigger checks look at
actions/checkoutsteps. Agit fetchorgh pr checkoutinside arun:step is not inspected. To forbid these triggers outright, useforbidden-triggersin a contract.
Try the SecureCI CLI
Free and open source (MIT). Needs Node.js 20+, or a standalone binary.
npm install -g @secureci/cli
secureci validate .github/workflows/*.yml
secureci init workflow
Linting one repository is a command. Knowing which of your organisation's repositories pass is an assessment. Request an assessment →
FAQ
How do I validate a GitHub Actions workflow without pushing?
Install the free SecureCI CLI and run secureci validate .github/workflows/ci.yml in your repository. It checks syntax, expressions and if: conditions, and reports security findings, without running any step. To see which jobs and steps would run, use secureci run with --dry-run.
What is the difference between a YAML linter and a GitHub Actions linter?
A YAML linter only checks that the file is valid YAML and formatted consistently. A GitHub Actions linter also understands what the file means: the workflow syntax, the ${{ }} expressions and the if: conditions. A file can be perfect YAML and still fail on GitHub.
Can I lint GitHub Actions workflows in CI?
Yes. Run secureci init workflow to write a pull request workflow that uses the SecureCI GitHub Action. It validates every file in .github/workflows and, by default, uploads a SARIF report so findings show up on the pull request in GitHub code scanning. The upload needs code scanning enabled for the repository.
Does a linter catch security problems in workflows?
Some do. secureci validate reports template injection, missing or excessive GITHUB_TOKEN permissions, pull_request_target and workflow_run jobs that check out and run untrusted code, and actions with known advisories in the GitHub Advisory Database, in the same pass as the syntax checks.
Is the SecureCI CLI free?
Yes. The SecureCI CLI is free and open source under the MIT license, for public and private repositories. An org-wide SecureCI platform for platform and security teams is in development, and pilot organisations can ask us for an assessment.