Boolean inputs are not actually booleans in composite actions
See original GitHub issueDescribe the bug
I’m not sure if closed issues are monitored, as there was no reaction from official side at all. This is a new issue related to https://github.com/actions/runner/issues/1483.
For composite actions boolean inputs are not actually booleans.
To Reproduce
inputs:
...
generate-release-notes:
description: ...
required: false
type: boolean
default: false
runs:
using: composite
steps:
- name: Create Release
uses: actions/github-script@v6
with:
script: |
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
...
generate_release_notes: ${{ inputs.generate-release-notes && 'true' || 'false' }}
});
Caller:
- uses: flobernd/actions/github/create-release@master
with:
tag-name: v1.2.4
generate-release-notes: true
This line always evaluates to false
:
generate_release_notes: ${{ inputs.generate-release-notes && 'true' || 'false' }}
The explicit syntax does incorrectly evaluate to false
as well:
generate_release_notes: ${{ inputs.generate-release-notes == true && 'true' || 'false' }}
Correct behavior is only observed when using string semantics:
generate_release_notes: ${{ inputs.generate-release-notes == 'true' && 'true' || 'false' }}
Expected behavior
generate_release_notes: ${{ inputs.generate-release-notes && 'true' || 'false' }}
generate_release_notes: ${{ inputs.generate-release-notes == true && 'true' || 'false' }}
Evaluates to true
.
Runner Version and Platform
GitHub managed runners (latest version). All platforms.
Issue Analytics
- State:
- Created a year ago
- Reactions:40
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Boolean input not passed correctly to reusable workflow
Booleans behave differently for workflow_dispatch and workflow_call , which is a misimplementation by github team and discussed in length ...
Read more >Github Not-So-Reusable Actions - smcleod.net
They are a way to reuse steps, but not workflows. Booleans in composite actions are actually Strings - even if you set their...
Read more >GitHub Actions: Input types for manual workflows
You can now specify input types for manually triggered workflows allowing you to ... we now support choice , boolean , and environment...
Read more >Compound Booleans with logical operators
We can implement any logic in a program using only nested conditionals. However, we can make shorter and more expressive code by combining...
Read more >Github Actions Passing Boolean to reusable workflow_call
workflow_dispatch Boolean inputs are not actually Booleans. workflow_dispatch reads Boolean inputs as string and if you try to evaluate them as Boolean it ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1 to this. Just recently ran into this exact issue, with the only reasonable workaround being to use string semantics as detailed in the original post.
Just ran into this issue as well. There doesn’t seem to be any related information on the official documentation, and it is very non-intuitive to have
inputs
support multiple types in workflows and “normal” actions but not in composite actions. I hope this behavior can be changed.