我一直在尝试在 Github 操作中构建 CICD 管道,但我们无法同时处理 if 和 or 条件。下面是我们的代码片段示例,
name: Build Non prod
needs: [rules]
if: ${{ (needs.rules.outputs.branch_name != 'production') || (needs.rules.outputs.branch_name != 'staging') }}
steps:
- name: Checkout
uses: actions/checkout@v2
所以这个任务应该在不运行production
和staging
分支,但在操作运行中staging
的分支,这份工作也越来越与并不意味着其他工作一起引发的staging
环境。
有什么办法可以拥有if
和or
条件吗?
更新:
该条件将不起作用,低于更新的条件将起作用。
if: ${{ (needs.rules.outputs.branch_name != 'production') && (needs.rules.outputs.branch_name != 'staging') }}
您的情况应如下所示:
name: Build Non prod
needs: [rules]
if: ${{ (needs.rules.outputs.branch_name != 'production') && (needs.rules.outputs.branch_name != 'staging') }}
steps:
- name: Checkout
uses: actions/checkout@v2
但是,如果您发现它不起作用,则可能与此问题有关 -如果跳过“needs”属性中的作业,则无法正确评估作业级别的“if”条件
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句