Expressions
You can evaluate expressions in workflows and actions.
In this article
About expressions
You can use expressions to programmatically set environment variables in workflow files and access contexts. An expression can be any combination of literal values, references to a context, or functions. You can combine literals, context references, and functions using operators. For more information about contexts, seeContexts reference.
Expressions are commonly used with the conditionalif
keyword in a workflow file to determine whether a step should run. When anif
conditional istrue
, the step will run.
You need to use specific syntax to tell GitHub to evaluate an expression rather than treat it as a string.
${{ <expression> }}
Note
The exception to this rule is when you are using expressions in anif
clause, where, optionally, you can usually omit${{
and}}
. For more information aboutif
conditionals, seeWorkflow syntax for GitHub Actions.
Warning
When creating workflows and actions, you should always consider whether your code might execute untrusted input from possible attackers. Certain contexts should be treated as untrusted input, as an attacker could insert their own malicious content. For more information, seeSecure use reference.
Example setting an environment variable
env:MY_ENV_VAR:${{<expression>}}
Further reading
For technical reference information about expressions you can use in workflows and actions, seeEvaluate expressions in workflows and actions.