小编Sam*_*dar的帖子

Github Actions 中的 If 或条件

我一直在尝试在 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)

因此,此任务不应在分支中运行productionstaging但是当操作在staging分支中运行时,此作业也会与不适合staging环境的其他作业一起被触发。

有什么办法可以拥有ifor条件吗?

更新:

该条件将不起作用,更新后的条件将起作用。

if: ${{ (needs.rules.outputs.branch_name != 'production') && (needs.rules.outputs.branch_name != 'staging') }}
Run Code Online (Sandbox Code Playgroud)

github github-actions cicd

19
推荐指数
1
解决办法
5万
查看次数

标签 统计

cicd ×1

github ×1

github-actions ×1