Boolean inputs are not actually booleans
Problem
>[!NOTE] > Although this has been fixed, see also: > - #2238 Describe the bug Boolean type inputs do not work as expected; they are strings instead of booleans, even when surrounded by `${{ }}` (e.g. in a step's `if` condition). To Reproduce Steps to reproduce the behavior: Run this workflow using the workflow dispatch, with the foo input checkbox not ticked: [code block] Expected behavior When the input is `false`, the `Run if foo` step should be skipped , and the `Don't run if foo` step should run. Runner Version and Platform Version of your runner? `2.284.0` OS of the machine running the runner? `ubuntu-latest (20.04.3)` What's not working? The value of `github.event.inputs.foo` is `false`, yet the `Run if foo` step runs and the `Don't run if foo` step is skipped. Additional context It is the same for a string input type or boolean input type (https://github.blog/changelog/2021-11-10-github-actions-input-types-for-manual-workflows/). Only `if: ${{ github.event.inputs.foo == 'true' }}` works. So the input must be being treated as a string. This goes against what the documentation says at https://docs.github.com/en/actions/learn-github-actions/expressions#about-expressions: >...evaluate an expression rather than treat it as a string. > >`${{ <expression> }}`
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Boolean inputs are not actually booleans
I guess this is a github service bug, sadly broken by design :(. the value of the workflow_dispatch payload is `'false'`, but both of us are expecting a boolean `false` and not a string. Why does this happen? `'false'` is a non empty string, which is truthy. [code block] However this might align to previous `workflow_dispatch` behavior, all inputs are strings like before. This is super inconsist
Trust Score
6 verifications
- 1
I guess this is a github service bug, sadly broken by design :(.
I guess this is a github service bug, sadly broken by design :(.
- 2
the value of the workflow_dispatch payload is `'false'`, but both of us are expe
Why does this happen? `'false'` is a non empty string, which is truthy. [code block] However this might align to previous `workflow_dispatch` behavior, all inputs are strings like before.
- 3
This is super inconsistent with reusable workflows `workflow_call` ( beta ), bec
[code block] [code block]
Validation
Resolved in actions/runner GitHub issue #1483. Community reactions: 21 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep