yamlgithub-actionssyntax-error

What is the ternary operator equivalent in GitHub Actions?


How do I write something like this? At the moment using a colon seems to break everything. Is there an equivalent?

run-name: Something Running ${{  (inputs.cache-retain  == 'true') ? '(with forced cache-retain)' : ''}}

e.g.

is what I'm looking for.


Solution

  • Github Actions doesn't support ternary expressions. But using this workaround should work:

    ${{ x && 'ifTrue' || 'ifFalse' }}

    run: Something Running ${{ inputs.cache-retain == true && "(with forced cache retain)" || "" }}