From 0517100e5f52b44b702bfe2e5ddcf65421ef04c8 Mon Sep 17 00:00:00 2001 From: Jakub Warczarek Date: Wed, 16 Aug 2023 14:44:31 +0200 Subject: [PATCH 1/4] Be more precise when expression syntax ${{ }} can be omitted --- data/reusables/actions/expression-syntax-if.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/reusables/actions/expression-syntax-if.md b/data/reusables/actions/expression-syntax-if.md index e27ec8693cf5..1fd93cd28404 100644 --- a/data/reusables/actions/expression-syntax-if.md +++ b/data/reusables/actions/expression-syntax-if.md @@ -1 +1 @@ -When you use expressions in an `if` conditional, you may omit the {% raw %}`${{ }}`{% endraw %} expression syntax because {% data variables.product.prodname_actions %} automatically evaluates the `if` conditional as an expression. Using the {% raw %}`${{ }}`{% endraw %} expression syntax turns the contents into a string, and strings are truthy. For example, `if: true && {% raw %}${{ false }}{% endraw %}` will evaluate to `true`. +When you use expressions in an `if` conditional, you may omit the {% raw %}`${{ }}`{% endraw %} expression syntax because {% data variables.product.prodname_actions %} automatically evaluates the `if` conditional as an expression. You can't omit the {% raw %}`${{ }}`{% endraw %} expression syntax when expression starts with {% raw %}`!`{% endraw %}, it's a limitation of YAML format. Using the {% raw %}`${{ }}`{% endraw %} expression syntax turns the contents into a string, and strings are truthy. For example, `if: true && {% raw %}${{ false }}{% endraw %}` will evaluate to `true`. From 0e268a5c2ec029f919c63eb99e3ea6d3bc42c3d8 Mon Sep 17 00:00:00 2001 From: Jakub Warczarek Date: Thu, 24 Aug 2023 10:47:07 +0200 Subject: [PATCH 2/4] Update data/reusables/actions/expression-syntax-if.md Co-authored-by: Joe Clark <31087804+jc-clark@users.noreply.github.com> --- data/reusables/actions/expression-syntax-if.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/reusables/actions/expression-syntax-if.md b/data/reusables/actions/expression-syntax-if.md index 1fd93cd28404..17d01f0c4c7d 100644 --- a/data/reusables/actions/expression-syntax-if.md +++ b/data/reusables/actions/expression-syntax-if.md @@ -1 +1 @@ -When you use expressions in an `if` conditional, you may omit the {% raw %}`${{ }}`{% endraw %} expression syntax because {% data variables.product.prodname_actions %} automatically evaluates the `if` conditional as an expression. You can't omit the {% raw %}`${{ }}`{% endraw %} expression syntax when expression starts with {% raw %}`!`{% endraw %}, it's a limitation of YAML format. Using the {% raw %}`${{ }}`{% endraw %} expression syntax turns the contents into a string, and strings are truthy. For example, `if: true && {% raw %}${{ false }}{% endraw %}` will evaluate to `true`. +When you use expressions in an `if` conditional, you may omit the {% raw %}`${{ }}`{% endraw %} expression syntax because {% data variables.product.prodname_actions %} automatically evaluates the `if` conditional as an expression. You must use the {% raw %}`${{ }}`{% endraw %} expression syntax when the expression starts with `!`, since `!` is reserved notation in YAML format. Using the {% raw %}`${{ }}`{% endraw %} expression syntax turns the contents into a string, and strings are truthy. For example, `if: true && {% raw %}${{ false }}{% endraw %}` will evaluate to `true`. From ef4507f3d5cb6bf9d308b7910c36bedb5c267fc0 Mon Sep 17 00:00:00 2001 From: Jakub Warczarek Date: Fri, 1 Sep 2023 14:16:40 +0200 Subject: [PATCH 3/4] Remove redundant information and add more escape possibilities --- content/actions/learn-github-actions/expressions.md | 1 - data/reusables/actions/expression-syntax-if.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/content/actions/learn-github-actions/expressions.md b/content/actions/learn-github-actions/expressions.md index 10448033b47f..4bd65bc15f1d 100644 --- a/content/actions/learn-github-actions/expressions.md +++ b/content/actions/learn-github-actions/expressions.md @@ -97,7 +97,6 @@ env: **Notes:** - {% data variables.product.company_short %} ignores case when comparing strings. - `steps..outputs.` 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 %} diff --git a/data/reusables/actions/expression-syntax-if.md b/data/reusables/actions/expression-syntax-if.md index 17d01f0c4c7d..40996a3b61ad 100644 --- a/data/reusables/actions/expression-syntax-if.md +++ b/data/reusables/actions/expression-syntax-if.md @@ -1 +1 @@ -When you use expressions in an `if` conditional, you may omit the {% raw %}`${{ }}`{% endraw %} expression syntax because {% data variables.product.prodname_actions %} automatically evaluates the `if` conditional as an expression. You must use the {% raw %}`${{ }}`{% endraw %} expression syntax when the expression starts with `!`, since `!` is reserved notation in YAML format. Using the {% raw %}`${{ }}`{% endraw %} expression syntax turns the contents into a string, and strings are truthy. For example, `if: true && {% raw %}${{ false }}{% endraw %}` will evaluate to `true`. +When you use expressions in an `if` conditional, you may omit the {% raw %}`${{ }}`{% endraw %} expression syntax because {% data variables.product.prodname_actions %} automatically evaluates the `if` conditional as an expression. You must use the {% raw %}`${{ }}`{% endraw %} expression syntax or escape with one of `''`, `""`, `()` when the expression starts with `!`, since `!` is reserved notation in YAML format. Using the {% raw %}`${{ }}`{% endraw %} expression syntax turns the contents into a string, and strings are truthy. For example, `if: true && {% raw %}${{ false }}{% endraw %}` will evaluate to `true`. From 3c62d524429bec1529cfd56215d017a4dd9882e7 Mon Sep 17 00:00:00 2001 From: Jakub Warczarek Date: Tue, 5 Sep 2023 21:03:05 +0200 Subject: [PATCH 4/4] Update data/reusables/actions/expression-syntax-if.md Co-authored-by: Joe Clark <31087804+jc-clark@users.noreply.github.com> --- data/reusables/actions/expression-syntax-if.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data/reusables/actions/expression-syntax-if.md b/data/reusables/actions/expression-syntax-if.md index 40996a3b61ad..14c942f3389e 100644 --- a/data/reusables/actions/expression-syntax-if.md +++ b/data/reusables/actions/expression-syntax-if.md @@ -1 +1,5 @@ -When you use expressions in an `if` conditional, you may omit the {% raw %}`${{ }}`{% endraw %} expression syntax because {% data variables.product.prodname_actions %} automatically evaluates the `if` conditional as an expression. You must use the {% raw %}`${{ }}`{% endraw %} expression syntax or escape with one of `''`, `""`, `()` when the expression starts with `!`, since `!` is reserved notation in YAML format. Using the {% raw %}`${{ }}`{% endraw %} expression syntax turns the contents into a string, and strings are truthy. For example, `if: true && {% raw %}${{ false }}{% endraw %}` will evaluate to `true`. +When you use expressions in an `if` conditional, you may omit the {% raw %}`${{ }}`{% endraw %} expression syntax because {% data variables.product.prodname_actions %} automatically evaluates the `if` conditional as an expression. However, this rule does not apply everywhere. + +You must use the {% raw %}`${{ }}`{% endraw %} expression syntax or escape with `''`, `""`, or `()` when the expression starts with `!`, since `!` is reserved notation in YAML format. + +Using the {% raw %}`${{ }}`{% endraw %} expression syntax turns the contents into a string, and strings are truthy. For example, `if: true && {% raw %}${{ false }}{% endraw %}` will evaluate to `true`.