I have the following GitHub worflow code:
- 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"
How can I make the if expression work?
CodePudding user response:
Try for testing
if: steps.projectcheck.outputs.central == 'true'
Ìf steps.projectcheck.outputs.central
is a string literal, you should not need ${{ }}
CodePudding user response:
I recommend to look into expressions in GitHub actions
if
conditional is treated as an expression, hence no explicit ${{ <expression> }}
is needed and you can write it like VonC mentioned.
But it's a good rule of thumb to use expressions everywhere, I'd recommend writing it like this:
if: ${{ steps.projectcheck.outputs.central == "true" }}