Jobs if condition does not work with workflow_dispatch inputs

The following build script doesn’t respect the job’s if condition. is it a bug or I’m making a mistake?


name: Build project

on:
  workflow_dispatch:
    inputs:
      buildForiOS:
        description: 'Build for iOS?'
        required: true
        default: 'true'

jobs:
    BuildForiOsPlatform:
      if: ${{ github.event.inputs.buildForiOS }} == 'true'
    # when buildForiOS is not true this shouldn't run but it always run !
      steps:
        - uses: actions/checkout@v2

I believe you need:
if: ${{ github.event.inputs.buildForiOS == 'true' }}

@kingthorin Good catch, Thanks a lot. It’s working now

1 Like

Great, glad you got it sorted out.

Hi @kingthorin, in the above code how can we stop the workflow when the input is set to null or if the input is not given?

!= ‘null’ or != ‘’ I believe.

If you set the default null in your workflow definition I’m not sure what will happen, but, just don’t do that and short yourself in the foot :slightly_smiling_face:

Alright, will try that.
Thanks for the response. :slightly_smiling_face: