admin管理员组

文章数量:1379913

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.

  • if true: 'Something running (with forced cache-retain)'
  • if false: 'Something running'

is what I'm looking for.

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.

  • if true: 'Something running (with forced cache-retain)'
  • if false: 'Something running'

is what I'm looking for.

Share Improve this question edited Mar 28 at 14:59 dankoiDev asked Mar 28 at 14:41 dankoiDevdankoiDev 1336 bronze badges 1
  • 4 Note this is not really "in YAML"; inside ${{ }} you're writing a GitHub Actions expression. – jonrsharpe Commented Mar 28 at 14:54
Add a comment  | 

1 Answer 1

Reset to default 1

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)" || "" }}

本文标签: yamlWhat is the ternary operator equivalent in GitHub ActionsStack Overflow