[英]If or condition in Github Actions
我一直在尝试在 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
但是,如果您发现它不起作用,则可能与此问题有关 -如果跳过“需要”属性中的作业,则作业级别的“如果”条件未正确评估
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.