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

Step if condition starting with ! fails parsing #753

Closed
EnricoMi opened this issue Oct 12, 2020 · 4 comments
Closed

Step if condition starting with ! fails parsing #753

EnricoMi opened this issue Oct 12, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@EnricoMi
Copy link

Describe the bug
My workflow has a step if condition that starts with a ! to negate the expression. The yaml file cannot be parsed: While parsing a tag, did not find expected tag URI.

To Reproduce
Steps to reproduce the behavior:

  1. Add this yaml to your repo under .github/workflow/:
name: "Issue"
on: [push]

jobs:
  condition:
    name: "Condition Issue"
    runs-on: ubuntu-latest

    steps:
    - name: Not false condition
      if: ! false
      run: echo "works"
  1. Commit and push to github, see the "Actions" tab, it will show you a failed action:

grafik

Expected behavior
The expression ! false should be resolved to true. This workflow file works when the expression is enclosed in round brackets: if: ( ! false ). Those brackets should not be required.

Runner Version and Platform

Version of your runner? Current

OS of the machine running the runner? Ubuntu

@EnricoMi EnricoMi added the bug Something isn't working label Oct 12, 2020
@davidkarlsen
Copy link

Try quoting the expression

@aabeling
Copy link

Had the same problem. Quoting the expression helped in my case.
But it is still a bug, isn't it?

@TingluoHuang
Copy link
Member

https://cloudslang-docs.readthedocs.io/en/v1.0/yaml_overview.html#scalars-strings-numbers-values

! is a special char in YAML, so you have to escape it. 😢

crgz added a commit to crgz/abbreviated_dates that referenced this issue Oct 10, 2022
crgz added a commit to crgz/abbreviated_dates that referenced this issue Oct 10, 2022
caendesilva added a commit to hydephp/hyde that referenced this issue Jan 3, 2023
jordanbaird added a commit to jordanbaird/ColorWell that referenced this issue Mar 29, 2023
@marcospgp
Copy link

Quoting the string with "" causes a syntax error with the GitHub Actions VSCode extension,

${{}} also shows up as red in if fields

And not using single quotes in contains(github.event.pull_request.labels.*.name, 'notests') also causes an error when running the workflow

So I had to resort to if: '!contains(github.event.pull_request.labels.*.name, ''notests'')'

So much complexity for such a simple thing 🥵

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants