question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Boolean inputs are not actually booleans in composite actions

See original GitHub issue

Describe 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:open
  • Created a year ago
  • Reactions:40
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
srempcommented, Jan 20, 2023

+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.

6reactions
agileshawcommented, Apr 28, 2023

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found