Sam*_*dar 19 github github-actions cicd
我一直在尝试在 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)
Krz*_*tof 19
您的条件应如下所示:
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)
但是,如果您发现它不起作用,则可能与此问题有关 -如果跳过“needs”属性中的作业,则作业级“if”条件无法正确评估
归档时间: |
|
查看次数: |
48623 次 |
最近记录: |