Skip to content
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

feat: describe conditional values #31252

Merged
merged 5 commits into from
Mar 5, 2024
Merged
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
4 changes: 3 additions & 1 deletion content/actions/learn-github-actions/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ As part of an expression, you can use `boolean`, `null`, `number`, or `string` d
| `number` | Any number format supported by JSON. |
| `string` | You don't need to enclose strings in `{% raw %}${{{% endraw %}` and `{% raw %}}}{% endraw %}`. However, if you do, you must use single quotes (`'`) around the string. To use a literal single quote, escape the literal single quote using an additional single quote (`''`). Wrapping with double quotes (`"`) will throw an error. |

Note that in conditionals, falsy values (`false`, `0`, `-0`, `""`, `''`, `null`) are coerced to `false` and truthy (`true` and other non-falsy values) are coerced to `true`.

### Example of literals

{% raw %}
Expand Down Expand Up @@ -125,7 +127,7 @@ env:
{% endraw %}

In this example, we're using a ternary operator to set the value of the `MY_ENV_VAR` environment variable based on whether the {% data variables.product.prodname_dotcom %} reference is set to `refs/heads/main` or not. If it is, the variable is set to `value_for_main_branch`. Otherwise, it is set to `value_for_other_branches`.
It is important to note that the first value after the `&&` condition must be `truthy` otherwise the value after the `||` will always be returned.
It is important to note that the first value after the `&&` must be truthy. Otherwise, the value after the `||` will always be returned.

## Functions

Expand Down