I have the following workflow in my GitHub actions:
name: Tests e2e iOS App
on:
workflow_dispatch:
inputs:
skip:
type: boolean
required: true
default: false
jobs:
build-simu-ios-zip:
name: Build iOS simulator zip
uses: ./.github/workflows/reusable-e2e-buildsimuioszip.yml
secrets: inherit
with:
environment: ${{ inputs.environment }}
I would like to run the job build-simu-ios-zip
conditionally, I add the following:
jobs:
build-simu-ios-zip:
name: Build iOS simulator zip
+ if: ${{ inputs.skip == 'false' }}
uses: ./.github/workflows/reusable-e2e-buildsimuioszip.yml
secrets: inherit
with:
environment: ${{ inputs.environment }}
But the job automatically get skipped.
I also tried to pass an input to the reusable workflow and make it conditionally it from there, but it also skip.
How can I make a conditional reusable workflow in GitHub action?
I made some tests here and using if: ${{ inputs.skip == 'false' }}
with single quotes '
doesn't work as you are comparing a boolean
type with a string
.
However, I found 2 options that worked:
if: ${{ inputs.skip == false }}
(no quote)
if: ${{ ! inputs.skip }}
(as it's a boolean input, but with !
)
Note: I used this workflow for tests.