Skip to content

Commit bc2957f

Browse files
authored
[EDI] Evaluate expressions in workflows and actions (#56486)
1 parent 1dc7040 commit bc2957f

File tree

3 files changed

+47
-32
lines changed

3 files changed

+47
-32
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: Expressions
3+
intro: 'You can evaluate expressions in workflows and actions.'
4+
versions:
5+
fpt: '*'
6+
ghes: '*'
7+
ghec: '*'
8+
type: overview
9+
topics:
10+
- Actions
11+
- Workflows
12+
---
13+
14+
## About expressions
15+
16+
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, see [AUTOTITLE](/actions/learn-github-actions/contexts).
17+
18+
Expressions are commonly used with the conditional `if` keyword in a workflow file to determine whether a step should run. When an `if` conditional is `true`, the step will run.
19+
20+
{% data reusables.actions.expressions-syntax-evaluation %}
21+
22+
{% raw %}
23+
`${{ <expression> }}`
24+
{% endraw %}
25+
26+
> [!NOTE]
27+
> The exception to this rule is when you are using expressions in an `if` clause, where, optionally, you can usually omit {% raw %}`${{`{% endraw %} and {% raw %}`}}`{% endraw %}. For more information about `if` conditionals, see [AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif).
28+
29+
{% data reusables.actions.context-injection-warning %}
30+
31+
### Example setting an environment variable
32+
33+
{% raw %}
34+
35+
```yaml
36+
env:
37+
MY_ENV_VAR: ${{ <expression> }}
38+
```
39+
40+
{% endraw %}
41+
42+
## Further reading
43+
44+
For technical reference information about expressions you can use in workflows and actions, see [AUTOTITLE](/actions/reference/evaluate-expressions-in-workflows-and-actions).

content/actions/concepts/workflows-and-actions/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ children:
1111
- /avoiding-duplication
1212
- /about-custom-actions
1313
- /contexts
14+
- /expressions
1415
- /about-monitoring-workflows
1516
- /notifications-for-workflow-runs
1617
- /about-troubleshooting-workflows

content/actions/reference/evaluate-expressions-in-workflows-and-actions.md

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Evaluate expressions in workflows and actions
3-
shortTitle: Expressions
4-
intro: You can evaluate expressions in workflows and actions.
3+
shortTitle: Expressions reference
4+
intro: Find information for expressions in {% data variables.product.prodname_actions %}.
55
versions:
66
fpt: '*'
77
ghes: '*'
@@ -12,36 +12,6 @@ redirect_from:
1212
- /actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions
1313
---
1414

15-
{% data reusables.actions.enterprise-github-hosted-runners %}
16-
17-
## About expressions
18-
19-
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, see [AUTOTITLE](/actions/learn-github-actions/contexts).
20-
21-
Expressions are commonly used with the conditional `if` keyword in a workflow file to determine whether a step should run. When an `if` conditional is `true`, the step will run.
22-
23-
{% data reusables.actions.expressions-syntax-evaluation %}
24-
25-
{% raw %}
26-
`${{ <expression> }}`
27-
{% endraw %}
28-
29-
> [!NOTE]
30-
> The exception to this rule is when you are using expressions in an `if` clause, where, optionally, you can usually omit {% raw %}`${{`{% endraw %} and {% raw %}`}}`{% endraw %}. For more information about `if` conditionals, see [AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif).
31-
32-
{% data reusables.actions.context-injection-warning %}
33-
34-
### Example setting an environment variable
35-
36-
{% raw %}
37-
38-
```yaml
39-
env:
40-
MY_ENV_VAR: ${{ <expression> }}
41-
```
42-
43-
{% endraw %}
44-
4515
## Literals
4616

4717
As part of an expression, you can use `boolean`, `null`, `number`, or `string` data types.

0 commit comments

Comments
 (0)