runner: INPUT_* environment variables are missing in composite actions

According to the documentation actions should receive their input values as environment variables prefixed with INPUT_ in addition to the inputs context. These environment variables are missing for composite actions.

To Reproduce Steps to reproduce the behavior:

  1. Create a composite action with one or more inputs, and a step that outputs the associated INPUT variables:
inputs:
  foo:
    description: 'Test input'
    required: yes
runs:
  using: composite
  steps:
    - run: |
        echo "FOO: ${INPUT_FOO}"
      shell: bash
  1. Use the action in a workflow:
steps:
  - uses: ./example-action
    with:
      foo: 'bar'
  1. Observe the lack of value after the FOO: prefix.

I have an example action and workflow (the uses: ./composite-action step) that demonstrate the issue and the obvious workaround. There’s a workflow run as well (check the “Run /./composite-action” step).

Expected behavior Steps should be able to read inputs via environment variables, INPUT_FOO in the example above, INPUT_NUM1 (to 4) in my reproducer.

Runner Version and Platform

Version of your runner?

  • 2.272.0

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

  • Ubuntu 20.04.1 LTS (Github hosted runner VM)

Job Log Output

From the workflow run linked above:

Run ./composite-action
  with:
    num1: 1
    num2: 4
    num3: 0
    num4: 0
Show INPUT vars
  INPUT_NUM1 = 
  INPUT_NUM2 = 
  INPUT_NUM3 = 
  INPUT_NUM4 = 
Add numbers

Credit

I became aware of the issue thanks to a post on the Github community forum and tried to reproduce the issue out of curiosity.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 54
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

When authoring a composite action, inputs must be mapped into inner steps using GitHub Actions expressions.

For example, map into the script directly:

inputs:
  foo:
    description: 'Test input'
    required: yes
runs:
  using: composite
  steps:
    - run: |
        echo "FOO: ${{inputs.foo}}"
      shell: bash

Or for example, map into the script indirectly via env var:

inputs:
  foo:
    description: 'Test input'
    required: yes
runs:
  using: composite
  steps:
    - run: |
        echo "FOO: $MY_VAR"
      shell: bash
      env:
        MY_VAR: ${{ inputs.foo }}

Fair enough, but wouldn’t it be simpler to have the same behavior across all kinds of actions? Or is there a technical reason not to provide the INPUT_ environment variables?

We need to update the referenced doc

👋 I’ve been using a workaround like _ericsciple’s:

inputs:
  branches:
    description: 'Branches to update'
    required: false
runs:
  using: "composite"
  steps:
    - run: my-awesome-action.sh
      shell: bash
      env:
        INPUT_BRANCHES: ${{ inputs.branches }}

I want to map the variable as INPUT_BRANCHES so I can reuse getInput() from the Actions SDK in my implementation. Using ${{input.branches}} directly in the command doesn’t work (Actions SDK can’t find it).

I’d dig a way to say “please forward ALL my action.yml:inputs to this step” without mapping every key. env: actionInputs(), actionInputs: true? Forwarding them without special configuration is 👍 too, but changing the exposure of existing composite actions is, as noted, bad.

(I wound up here after adding an input and forgetting about needing this hack to forward it. ~10% of my current action.yaml is input forwarding boilerplate)

I’ve hit that as well.

After some thought I imagine it’s because if, in future, they enable composite steps to contain other uses actions (not just shell runs), this would cause confusion in those sub-actions which inputs are theirs, and which are the parent composite action’s.

Better documentation definitely will help there. 😃 edit I think it’s also important to include the inputs context in the Contexts documentation, because currently it’s not there.

The issue still exists but thanks to the above workaround, which works.

Wondering any updates or plans on this?

I seem to have stumbled on another corner case in an action.

The inputs.xyz seem to disappear after a step that uses a with:, they (inputs.) are no longer available for other steps.

ci.yaml. (steps: uses action1 passing inputs in with:) action1.yaml ( halfway through uses action2 passing inputs in with:) after this step in action1.yaml all the input.xyz seem to be empty.

Work around by adding all to env. echo "password=${{ inputs.password }}" |tee -a $GITHUB_ENV

It is, thank you.

@burner1024: The doc now mentions this. I’m not sure if that’s any actual comfort.

Speaking as someone with a fairly large number of them, this is moderately annoying: https://github.com/check-spelling/check-spelling/blob/5c726fe37eed6f0ed3aba58fc418ca2c0edfbbf9/action.yml#L168-L189

What the… A year, and not only it’s not recognized as a bug, even the doc is not updated to help people in the meatime.