Skip to content

Add explanation of ordinal comparison of strings using the < and > operators #25870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions content/actions/learn-github-actions/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You can use expressions to programmatically set environment variables in workflo

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.

You need to use specific syntax to tell {% data variables.product.prodname_dotcom %} to evaluate an expression rather than treat it as a string.
{% data reusables.actions.expressions-syntax-evaluation %}

{% raw %}
`${{ <expression> }}`
Expand Down Expand Up @@ -80,7 +80,7 @@ env:
| Operator | Description |
| --- | --- |
| `( )` | Logical grouping |
| `[ ]` | Index
| `[ ]` | Index |
| `.` | Property de-reference |
| `!` | Not |
| `<` | Less than |
Expand All @@ -92,6 +92,16 @@ env:
| `&&` | And |
| <code>\|\|</code> | Or |

{% note %}

**Notes:**
- {% data variables.product.company_short %} ignores case when comparing strings.
- `steps.<step_id>.outputs.<output_name>` evaluates as a string. {% data reusables.actions.expressions-syntax-evaluation %} For more information, see "[AUTOTITLE](/actions/learn-github-actions/contexts#steps-context)."
- {% data reusables.actions.expression-syntax-if %} For more information about `if` conditionals, see "[AUTOTITLE](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif)."
- For numerical comparison, the `fromJSON()` function can be used to convert a string to a number. For more information on the `fromJSON()` function, see "[fromJSON](#fromjson)."

{% endnote %}

{% data variables.product.prodname_dotcom %} performs loose equality comparisons.

- If the types do not match, {% data variables.product.prodname_dotcom %} coerces the type to a number. {% data variables.product.prodname_dotcom %} casts data types to a number using these conversions:
Expand Down
1 change: 1 addition & 0 deletions data/reusables/actions/expressions-syntax-evaluation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
You need to use specific syntax to tell {% data variables.product.prodname_dotcom %} to evaluate an expression rather than treat it as a string.