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:
- 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
- Use the action in a workflow:
steps:
- uses: ./example-action
with:
foo: 'bar'
- 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
- Neaten variable handling and push tags conditionally Correct input env vars see actions/runner/issues/665 — committed to expipiplus1/action-automation by expipiplus1 4 years ago
- Set environment according to https://github.com/actions/runner/issues/665 — committed to 49nord/nix-container-build by mbr 4 years ago
- Some kind of work around from here: https://github.com/actions/runner/issues/665#issuecomment-676581170 — committed to mearns/node-template by mearns 4 years ago
- fix: Don't use $INPUT_ env vars They don't work in composite actions, and this is not documented because why not? See actions/runner#665 — committed to getsentry/action-prepare-release by BYK 4 years ago
- [inputs] https://github.com/actions/runner/issues/665 — committed to cvmfs-contrib/github-action-cvmfs by wdconinc 4 years ago
- Merge pull request #3 from cvmfs-contrib/bugfix-actions-runner-issues-665 [inputs] https://github.com/actions/runner/issues/665 — committed to cvmfs-contrib/github-action-cvmfs by wdconinc 4 years ago
- [inputs] https://github.com/actions/runner/issues/665 — committed to petricm/github-action-cvmfs by wdconinc 4 years ago
- fix: pass INPUT_TOKEN via env Ref. https://github.com/actions/runner/issues/665 — committed to syndesisio/backport-action by zregvart 4 years ago
- fix: pass INPUT_TOKEN via env Ref. https://github.com/actions/runner/issues/665 — committed to syndesisio/backport-action by zregvart 4 years ago
- fix: Use GitHub Actions expressions for args As per the documentation, we were using INPUT_* variables to pass the action input parameters to the scripts that expected them. But there seems to be ei... — committed to emphori/actions by iainjreid 4 years ago
- Manually set INPUT_* variables until actions/runner#665 is resolved — committed to jtdor/build-deb-action by jtdor 4 years ago
- Adds composite info about inputs and environment variables. Adds information regarding the INPUT_ environment variable conversion as discussed at actions/runner#665. — committed to fabriciomurta/docs by fabriciomurta 3 years ago
- Use GitHub expressions instead of environment variables Due to https://github.com/actions/runner/issues/665 — committed to wistia/github-action-build-workflow-images by deleted user 3 years ago
- Work around INPUT_* missing in composite action (JIRA BLD-5704) See https://github.com/actions/runner/issues/665 — committed to ccdc-opensource by siong-chin 3 years ago
- Work around INPUT_* missing in composite action (JIRA BLD-5704) See https://github.com/actions/runner/issues/665 — committed to ccdc-opensource by siong-chin 3 years ago
- uses inputs.version instead of $INPUTS_VERSION reason: https://github.com/actions/runner/issues/665 — committed to CSchoel/release-notes-from-changelog by CSchoel 3 years ago
- fuck this... ref https://github.com/actions/runner/issues/665 — committed to BGforgeNet/msg2po by burner1024 3 years ago
- Clarify how INPUT_<VARIABLE_NAME> works or doesn't See actions/runner#665 — committed to jsoref/github-docs by jsoref 3 years ago
- Clarify how INPUT_<VARIABLE_NAME> works or doesn't See actions/runner#665 — committed to jsoref/github-docs by jsoref 3 years ago
When authoring a composite action, inputs must be mapped into inner steps using GitHub Actions expressions.
For example, map into the script directly:
Or for example, map into the script indirectly via env var:
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:
I want to map the variable as
INPUT_BRANCHES
so I can reusegetInput()
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.