expressions.md: Provide an example of negation
Why:
! contains() (with a space) invalidates a workflow file and its jobs will not run. !contains() (no space) works as expected. Unfortunately, the GitHub web UI editor suggests the exact opposite of the correct syntax. It marks the solution that works as an error and the solution that does not work as being correct.
What's being changed (if available, include any code snippets, screenshots, or gifs):
Check off the following:
- [x] I have reviewed my changes in staging (look for the "Automatically generated comment" and click the links in the "Preview" column to view your latest changes).
- [x] For content changes, I have completed the self-review checklist.
Writer impact (This section is for GitHub staff members only):
- [ ] This pull request impacts the contribution experience
- [ ] I have added the 'writer impact' label
- [ ] I have added a description and/or a video demo of the changes below (e.g. a "before and after video")
Automatically generated comment âšī¸
This comment is automatically generated and will be overwritten every time changes are committed to this branch.
The table contains an overview of files in the content directory that have been changed in this pull request. It's provided to make it easy to review your changes on the staging site. Please note that changes to the data directory will not show up in this table.
Content directory changes
You may find it useful to copy this table into the pull request summary. There you can edit it to share links to important articles or changes and to give a high-level overview of how the changes in your pull request support the overall goals of the pull request.
| Source | Preview | Production | What Changed |
|---|---|---|---|
actions/learn-github-actions/expressions.md |
fpt ghec ghes@ 3.6 3.5 3.4 3.3 3.2 ghae |
fpt ghec ghes@ 3.6 3.5 3.4 3.3 3.2 ghae |
fpt: Free, Pro, Team ghec: GitHub Enterprise Cloud ghes: GitHub Enterprise Server ghae: GitHub AE
@cclauss Thanks so much for opening a PR! I'll get this triaged for review :zap:
đ Hi @cclauss, thanks for this PR!
Unfortunately, the GitHub web UI editor suggests the exact opposite of the correct syntax.
I'm not 100% what you're referring to here, but I suspect you might be using it with an if condition like:
if: !contains('Hello world', 'llo')
which, if that is the case, it is invalid because YAML doesn't allow an unquoted value to start with a special character. To escape the negation special character (!), you would need to use the expression syntax, such as:
if: ${{ !contains('Hello world', 'llo') }}
For your PR, I don't think a negated example is necessary here (for example, none of the other functions contain them).
Possibly a better change would be to mention the escaping requirement in the About expressions section.
e.g instead of
When you use expressions in an if conditional, you may omit the expression syntax (${{ }}) because GitHub automatically evaluates the if conditional as an expression. For more information about if conditionals, see "Workflow syntax for GitHub Actions."
we could mention the special character requirement:
When you use expressions in an if conditional, you may omit the expression syntax (${{ }}) if the expression does not start with a special character, because GitHub automatically evaluates the if conditional as an expression. For more information about if conditionals, see "Workflow syntax for GitHub Actions."
Let us know if you'd like to update this PR with that change đââī¸
A stale label has been added to this pull request because it has been open 7 days with no activity. To keep this PR open, add a comment or push a commit within 3 days.
A stale label has been added to this pull request because it has been open 7 days with no activity. To keep this PR open, add a comment or push a commit within 3 days.
I have updated the pr with the requested change.
I have updated the pr with the requested change.
Hi, @cclauss, it looks like you might have misread my suggestion.
You're current changes (if: {% raw %}${{ ! <expression> }}{% endraw %}) isn't totally accurate because ! is actually part of an expression.
Here's my suggestion again:
Possibly a better change would be to mention the escaping requirement in the About expressions section.
e.g instead of
When you use expressions in an if conditional, you may omit the expression syntax (${{ }}) because GitHub automatically evaluates the if conditional as an expression. For more information about if conditionals, see "Workflow syntax for GitHub Actions."
we could mention the special character requirement:
When you use expressions in an if conditional, you may omit the expression syntax (${{ }}) if the expression does not start with a special character, because GitHub automatically evaluates the if conditional as an expression. For more information about if conditionals, see "Workflow syntax for GitHub Actions."
Let us know if you'd like to update this PR with that change đââī¸
A stale label has been added to this pull request because it has been open 7 days with no activity. To keep this PR open, add a comment or push a commit within 3 days.