我一直在尝试在 Github actions 中构建 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
Run Code Online (Sandbox Code Playgroud)
因此,此任务不应在分支中运行production,staging但是当操作在staging分支中运行时,此作业也会与不适合staging环境的其他作业一起被触发。
有什么办法可以拥有if和or条件吗?
更新:
该条件将不起作用,更新后的条件将起作用。
if: ${{ (needs.rules.outputs.branch_name != 'production') && (needs.rules.outputs.branch_name != 'staging') }}
Run Code Online (Sandbox Code Playgroud)