Skip to content
Latchkey

How to Lint YAML with yamllint in GitHub Actions

YAML is whitespace-sensitive and unforgiving; yamllint turns a silent indentation bug into a clear CI failure.

Run yamllint across the repo with a tuned config so structural and style issues fail the job.

Steps

  • Install yamllint with pip.
  • Add a .yamllint config to relax rules like line length where appropriate.
  • Run yamllint . and let failures fail the build.

Workflow

.github/workflows/yamllint.yml
name: yamllint
on: [pull_request]
jobs:
  yamllint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
      - run: pip install yamllint
      - run: yamllint -c .yamllint .

Notes

  • Relax line-length in .yamllint so long URLs in config do not fail the lint.
  • On Latchkey managed runners YAML lint jobs run cheaper and self-heal if a runner dies.

Related guides

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