GitHub Actions "The template is not valid: invalid programming construct"
Workflow ${{ }} expressions support a limited grammar. Using an unsupported operator, statement, or nesting that the template engine cannot evaluate yields an "invalid programming construct" error.
What this error means
The workflow fails to start with "The template is not valid: ... invalid programming construct", pointing at a complex or malformed expression.
github-actions
Error: The template is not valid. .github/workflows/ci.yml (Line: 14, Col: 11): The directive 'invalid' is not allowed in this context. Invalid programming construct.Common causes
Unsupported expression operator/construct
The expression used something outside the supported functions/operators (an unknown directive or statement form).
Malformed nested expression
Mismatched braces or improperly nested ${{ }} produced an unparseable construct.
How to fix it
Use only supported expression syntax
- Rewrite the logic with supported functions (contains, fromJSON, format).
- Move complex logic into a run step instead of the expression.
- Check brace matching and nesting in ${{ }}.
.github/workflows/ci.yml
# move complex logic into a script, expose a simple output
- id: gate
run: echo "go=true" >> "${GITHUB_OUTPUT}"
- if: steps.gate.outputs.go == 'true'
run: make deployHow to prevent it
- Keep ${{ }} expressions within the supported grammar.
- Push complex conditionals into run steps with outputs.
- Lint expressions with actionlint.
Related guides
GitHub Actions "The template is not valid" expression evaluation errorFix the GitHub Actions "The template is not valid" runtime expression evaluation error caused by a function o…
GitHub Actions "Unexpected symbol" in a ${{ }} ExpressionFix GitHub Actions "The workflow is not valid ... Unexpected symbol" - a malformed expression: unquoted strin…
GitHub Actions "This run likely failed because of a workflow file issue"Fix the GitHub Actions startup failure "This run likely failed because of a workflow file issue" - the workfl…