I'm developing a GitHub Action for marketplace. It has various inputs with default values. One of these inputs happen to be a boolean
which I use to toggle debugging status.
Here's my boolean input definition:
inputs:
debug_mode:
description: "Controls the debug mode, boolean, true is for on. When turned on, it'll output certain information on certain steps. Mainly used for development, but use it as you please to inspect your env and variables."
type: boolean
required: false
default: false
As you can see it has the type boolean
with default value false
.
Then in one of the steps, I check debug_mode
to determine whether to run the step or not. However, it is not working as expected:
steps:
- name: Dump debug_mode
run: echo "debug_mode is ${{ inputs.debug_mode }}"
shell: bash
- name: Dump context
if: ${{ inputs.debug_mode}}
uses: crazy-max/ghaction-dump-context@v2
- name: Dump build_path
if: ${{ inputs.debug_mode}}
run: echo "build_path is ${{ inputs.build_path }}"
When the action runs, I see that debug_mode is false
is printed via echo
. Nonetheless, 'Dump Context' step runs even though debug_mode
is false. I tried giving this input value explicitly true
or false
, also tried it without assigning a value (using default), still didn't get a consistent result. I read somewhere that it could be due to the fact I'm running in via workflow_run
.
For reference and easier time detecting the issue, here is the original sources:
In clearance, my aim is to run certain steps only if debug_mode
is true
. I would like to use boolean
type if possible, because string is semantically incorrect.
Thank you in advance.
For actions, the type
parameter is not supported for inputs
.
Maybe, you thought it would be the same as on.workflow_dispatch.inputs.<input_id>.type
as in a workflow but it is not.
As for default
, it takes a string
value, not a Boolean. See its JSON schema here. VS Code automatically highlights these issues using this JSON schema. You might have to install its YAML extension.
If you want to handle it under Boolean context, use 'true'
or 'false'
as strings and use it accordingly.
So, the inputs
would be:
inputs:
debug_mode:
description: '...'
required: false
default: 'false'
and, for true
case, the if
condition would be:
if: ${{ inputs.debug_mode == 'true' }}