Boolean inputs are not actually booleans
See original GitHub issueDescribe 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:
name: Thingy
on:
workflow_dispatch:
inputs:
foo:
description: Whether to foo
type: boolean
required: false
default: false
jobs:
thingy:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
FOO: ${{ github.event.inputs.foo }}
steps:
- name: Check value
run: |
echo "The value is: $FOO"
- name: Run if foo
if: ${{ github.event.inputs.foo }}
run: |
echo "Foo!"
- name: Don't run if foo # Eh, I meant "Run if not foo"
if: ${{ ! github.event.inputs.foo }}
run: |
echo "Foo!"
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> }}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:143
- Comments:47 (10 by maintainers)
Something that I also recently learned is that booleans are “strings” within workflow dispatches and composite actions but not reusable workflows.
For workflow_dispatch and composite action boolean inputs are actually strings:
and
will work.
However, for reusable workflows, the boolean is actually a boolean:
or
References
👋 We are working on some efforts in unifying the inputs context and will address these issues in future. So it should behave like inputs.boolean == true instead of strings (“true”) We will update once rolled out.