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.

Inputs context not available in reusable workflows

See original GitHub issue

Describe the bug The inputs context does not seem available in the with context of reusable workflows

To Reproduce

  • Create a reusable workflow that has the following input
      stg_image_build:
        description: whether to build the staging image
        required: true
        type: boolean
        default: false

Invoke it as follows

  workflow_dispatch:
    inputs:
      push_to_stg:
        description: "Build and push image to staging registry"
        type: boolean
        default: false
        required: true

...

  build-and-push-image:
    needs:
      - echo-input
    uses: Org/repo/.github/workflows/myreusableworkflow.yaml@master
    with:
      stg_image_build: ${{ inputs.push_to_stg }}

Fails

The template is not valid. .github/workflows/calling.yaml (Line: 15, Col: 24): Unexpected type of value '', expected type: Boolean.

Expected behavior The stg_image_build: ${{ inputs.push_to_stg }} line should be passing to the reusable workflow a boolean.

Runner Version and Platform

GitHub hosted runner

OS of the machine running the runner? OSX/Windows/Linux/… ubuntu-latest

What’s not working?

The template is not valid. .github/workflows/calling.yaml (Line: 15, Col: 24): Unexpected type of value '', expected type: Boolean.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jensengcommented, May 2, 2023

@galcohen-redislabs @jtmullen I ran into a similar issue, it appears that the type gets lost somewhere in the process and those input values become strings. As a workaround, you should be able to use fromJSON to convert them back to the appropriate type (e.g. number, boolean). For example, instead of this:

jobs:
   ...
   with:
      my_timeout: ${{ inputs.timeout }}

give this a try:

jobs:
   ...
   with:
      my_timeout: ${{ fromJSON(inputs.timeout) }} # 🙈 
2reactions
jtmullencommented, Apr 12, 2023

@ruvceskistefan I am also still seeing this same issue:

Have a number input via workflow_dispatch that is being directly passed as an input to a reusable workflow:

The template is not valid. .....yml (Line: 29, Col: 23): Unexpected type of value '1', expected type: Number.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reusing workflows
To reuse variables in multiple workflows, set them at the organization, repository, or environment levels and reference them using the vars context. For...
Read more >
Why is env context not available in Github action job level if ...
The documentation reads. You can access this context from any step in a job. This object contains the properties listed below. ~ env...
Read more >
Inputs unified across manual and reusable workflows
For workflows triggered by workflow_dispatch inputs are still available in the github.event.inputs context to maintain compatibility.
Read more >
How to start using reusable workflows with GitHub Actions
Inputs are used to pass non-sensitive information while secrets are used to pass along sensitive information such as passwords and credentials.
Read more >
Avoid Duplication! GitHub Actions Reusable Workflows
Note: if a required input has not been passed to the reusable workflow, it will fail. Other available types are boolean and number...
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