我一直在尝试在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
因此,此任务不应在production
和staging
分支中运行,但是当操作在staging
分支中运行时,此作业也会与其他不适用于staging
环境的作业一起触发。
有没有办法使用if
和or
条件?
更新:
该条件无效,下面是更新后的条件:
if: ${{ (needs.rules.outputs.branch_name != 'production') && (needs.rules.outputs.branch_name != 'staging') }}
if: ${{ (needs.rules.outputs.branch_name != 'production') && (needs.rules.outputs.branch_name != 'staging') }}
当它处于暂存或生产环境中时,下面的代码片段将告诉操作运行而不是跳过if: ${{ (needs.rules.outputs.branch_name != 'production') ||(needs.rules.outputs.branch_name != 'staging') }}
- Sam-Sundar