-
Notifications
You must be signed in to change notification settings - Fork 962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boolean inputs are not actually booleans #1483
Comments
- Nightly build timing out - `if` condition in deploy workflow doesn't work as expected - actions/runner#1483
I guess this is a github service bug, sadly broken by design :(. the value of the workflow_dispatch payload is
However this might align to previous This is super inconsistent with reusable workflows name: called
on:
workflow_call:
inputs:
x:
type: boolean
jobs:
test1:
runs-on: ubuntu-latest
steps:
- run: echo '${{inputs.x}}'
if: ${{inputs.x}} name: caller
on:
push:
jobs:
test2:
uses: <owner>/<repo>/.github/workflows/called.yml@<ref>
with:
x: false |
if:
I have run into this issue as well, it is tricky to identify and debug. I have just been ensuring I always cast potential boolean values to a string, and always match on the string value. |
@ericsciple do you have any thoughts on this? |
Seems like input field type in workflow is only for GitHub to know what UI controls should it use and all inputs are strings... So it seems we should check it like |
@piotrekkr it is the same for outputs, for example: outputs:
foo:
description: "Returns true or false"
value: ${{ steps.foo.outputs.bar == 'true' }} The outputs:
foo:
description: "Returns true or false"
value: "${{ steps.foo.outputs.bar == 'true' }}" And then match on |
@solarmosaic-kflorence Yeah they should clearly document this behavior it can be really confusing. Maybe there is some documentation mentioning this but I did not stumbled upon this for a year now when working with GitHub... |
This is actually really bad because there's no way to write a workflow such that if this bug is fixed your workflow continues to operate as normal. I can't figure out an expression that returns true only if a variable is not the string |
Have you tried You can also cast the input to a string with |
@scottmmjackson Seems like something like this could work I think (still seems quite ugly):
should give
//EDIT Ok seems like it may not work with empty strings because javascript...
|
I have a similar case by reusing workflows where I want let the caller of the reused workflow decide about I found the following workaround, where the input variable type is
|
Many people are confused by the usage of boolean. actions/runner#1483 invalid if: ${{ inputs.perform_deploy }} if: inputs.perform_deploy Must be treated as string
This comment was marked as outdated.
This comment was marked as outdated.
I updated my comment above because the input variable type has to be |
well, this is still not working as expected. putting if: ${{ inputs.SOME_BOOLEAN }} doesn't evaluate booleans. |
@Kristonitas I think those issues you added in screenshot were about output params and not inputs. Maybe outputs were mixed with inputs by some people and those were incorrectly linked to this issue. |
It's working great for me, can you provide an example? |
@libermansa The scenario that was reported in #1483 (comment) (and other similar tests) is not happening right now @piotrekkr P. S. The arguments passed between workflows are still serialised as strings afaik (hence you can't use json booleans when using the json input flag |
I found that I needed to use |
…affect some stuff, look into comments) Based of an issue ticket opened on 'actions/runners' GitHub Repo, link to it: actions/runner#1483
Still happens in env at least. I had to use inputs:
dev:
description: "Also add development requirements"
default: false
type: boolean
steps:
- env:
ARG_DEV: ${{ fromJSON(inputs.dev) && '--dev' || '' }}
run: pipenv install $ARG_DEV
shell: bash |
To solve chicken/egg problem of providing galera workers to build the galera-4 package. nogalera defined as string due to actions/runner#1483. It defaults to true, so the few build images that don't set it (mainly about to be EOL distros), or new distros that accidently omit it won't fail.
To solve chicken/egg problem of providing galera workers to build the galera-4 package. nogalera defined as string due to actions/runner#1483. It defaults to true, so the few build images that don't set it (mainly about to be EOL distros), or new distros that accidently omit it won't fail.
To solve chicken/egg problem of providing galera workers to build the galera-4 package. nogalera defined as string due to actions/runner#1483. It defaults to true, so the few build images that don't set it (mainly about to be EOL distros), or new distros that accidently omit it won't fail.
…on `workflow_call`? refer: actions/runner#1483 (comment)
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'sif
condition).To Reproduce
Steps to reproduce the behavior:
Run this workflow using the workflow dispatch, with the foo input checkbox not ticked:
Expected behavior
When the input is
false
, theRun if foo
step should be skipped , and theDon'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
isfalse
, yet theRun if foo
step runs and theDon'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:
The text was updated successfully, but these errors were encountered: