如果条件在我的 git 工作流程中不起作用
If condition not working in my git workflow
我有以下 GitHub 工作流代码:
- name: Check if the project is central
id: projectcheck
run: echo "::set-output name=central::${{ contains(github.event.inputs.project, 'central') }}"
- name: output
run: echo ${{ steps.projectcheck.outputs.central }}
--- here I am getting true/false correctly based on the input project but the below if conditions are not working
- name: if central
if: ${{ steps.projectcheck.outputs.central }} == "true"
run: echo "central"
- name: if not central
if: ${{ steps.projectcheck.outputs.central }} == "false"
run: echo "central"
如何使 if 表达式起作用?
尝试测试
if: steps.projectcheck.outputs.central == 'true'
Ìf steps.projectcheck.outputs.central
是一个 string literal,你应该不需要 ${{ }}
我建议查看 expressions in GitHub actions
if
条件被视为表达式,因此不需要明确的 ${{ <expression> }}
,您可以像提到的 VonC 那样编写它。
但是到处使用表达式是一个很好的经验法则,我建议这样写:
if: ${{ steps.projectcheck.outputs.central == "true" }}
我有以下 GitHub 工作流代码:
- name: Check if the project is central
id: projectcheck
run: echo "::set-output name=central::${{ contains(github.event.inputs.project, 'central') }}"
- name: output
run: echo ${{ steps.projectcheck.outputs.central }}
--- here I am getting true/false correctly based on the input project but the below if conditions are not working
- name: if central
if: ${{ steps.projectcheck.outputs.central }} == "true"
run: echo "central"
- name: if not central
if: ${{ steps.projectcheck.outputs.central }} == "false"
run: echo "central"
如何使 if 表达式起作用?
尝试测试
if: steps.projectcheck.outputs.central == 'true'
Ìf steps.projectcheck.outputs.central
是一个 string literal,你应该不需要 ${{ }}
我建议查看 expressions in GitHub actions
if
条件被视为表达式,因此不需要明确的 ${{ <expression> }}
,您可以像提到的 VonC 那样编写它。
但是到处使用表达式是一个很好的经验法则,我建议这样写:
if: ${{ steps.projectcheck.outputs.central == "true" }}