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.

Cannot use inputs in non-composite actions

See original GitHub issue

Describe the bug No matter what I try, I cannot get inputs to work with non-composite actions. I’m allowed to define them, and trigger an action via API whilst providing inputs, but they cannot be referenced and don’t show up as env vars later in the action (non-composite). I suspect the answer here is “you can’t do that”, however:

  • I should be able to, why no? It’d be helpful
  • The docs don’t say that, and even if you disagree with the former point, you should support accurate docs.

To Reproduce create an action looking roughly like this:

name: test_workflow

on:
  workflow_dispatch:
    inputs:
      varname:
        required: true
        description: 'a test varname'

jobs:
  test:
    name: test
    runs-on: ubuntu-20.04

    steps:
      # Checks-out repository under $GITHUB_WORKSPACE
      - name: Checkout commit
        uses: actions/checkout@v2
        with:
          fetch-depth: 1

      # Print inputs
      - name: Print inputs
        run: echo ${{ inputs.varname }}

i also tried just using INPUTS_VARNAME, dumping env, etc. nothing worked. Either got Unrecognized named-value: 'inputs' as an error, the variable resolved to nothing, and when I dumped env there were no inputs present.

Expected behavior Either inputs should work (ideal), or the docs should explicitly say “this only works with composite actions”.

What’s not working?

Either got Unrecognized named-value: 'inputs' as an error, the variable resolved to nothing, and when I dumped env there were no inputs present.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
Crisfolecommented, Jan 27, 2023

I know this is old, but this continues to be a footgun, and the new docs (https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow) are not convoluted to interpret. They explicitly claim and use as an example that ${{ inputs.name }} should work.

In the reusable workflow, reference the input or secret that you defined in the on key in the previous step.

with the demo code:

...
jobs:
  print-username:
    runs-on: ubuntu-latest

    steps:
      - name: Print the input name to STDOUT
        run: echo The username is ${{ inputs.username }}
6reactions
hrosscommented, Apr 2, 2021

The docs are a bit convoluted to interpret, but the issue you are having is you aren’t using the github context (documented here in the context section of the expression syntax guide). Combining that with the docs for the workflow dispatch event you can rewrite:

      # Print inputs
      - name: Print inputs
        run: echo ${{ inputs.varname }}

as the following to access inputs in your example yaml file:

      # Print inputs
      - name: Print inputs
        run: echo ${{ github.event.inputs.varname }}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use inputs variable as a tag in composite action
In order to enact policies like only using actions defined in the org or repo we can't allow actions to dynamically change at...
Read more >
Input System bugs
Hi, I've been trying the new input system and so far I really like it! ... Exception: Cannot find public field 05 in...
Read more >
Standard Composite Controls - Documentation - SAPUI5 SDK
For application developers, the composite control is a black box, therefore, an application developer cannot distinguish a composite control from native ...
Read more >
Warning Log - RISA
Warning Number Warning Log Message Cause WARNING 41023 Optimize concrete beam solver error. The concrete beam solver h... WARNING 41095 Round Shapes for Beams are...
Read more >
VTK/Tutorials/Composite Datasets - KitwarePublic
Here's an example showing the use of an iterator to iterate over non-empty, non-composite dataset nodes. <source lang="cpp"> ...
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