GitHub Actions "Invalid workflow file ... error in your yaml syntax" in CI
GitHub parses .github/workflows/*.yml before scheduling jobs. If the YAML does not parse, the run fails immediately with "Invalid workflow file" and "You have an error in your yaml syntax on line N", naming the offending line.
What this error means
The Actions run is annotated red with "Invalid workflow file: .github/workflows/ci.yml" and "You have an error in your yaml syntax on line N". No jobs start.
Invalid workflow file: .github/workflows/ci.yml#L12
You have an error in your yaml syntax on line 12Common causes
A YAML parse error in the workflow
A tab, a bad indent, an unquoted colon, or a missing key at the reported line stops the parser before the workflow schema is even checked.
The reserved "on:" key mis-indented or mistyped
Breaking the top-level on: / jobs: / steps: structure produces a syntax error rather than a schema error.
How to fix it
Fix the YAML at the reported line
- Open the workflow at the
#L12line the annotation links to. - Check for tabs, wrong indentation, or an unquoted colon in a value.
- Push the fix; a valid file lets jobs schedule again.
# validate locally before pushing
yamllint .github/workflows/ci.ymlLint workflows in a pre-push or pre-commit hook
Run yamllint (or actionlint) on .github/workflows so syntax errors never reach GitHub.
- id: yamllint
name: yamllint workflows
entry: yamllint .github/workflows
language: systemHow to prevent it
- Lint workflow files locally with yamllint or actionlint.
- Never use tabs in workflow YAML.
- Quote values that contain colons.