INPUT_<VARIABLE_NAME> is not available in Composite run steps

According to the document, GitHub creates an environment variable for the input with the name INPUT_<VARIABLE_NAME>, but it’s not available with composite run steps.

I know we can access input value with expression syntax, but env variables are convenient especially when there are many inputs.

Is this expected? Can you define the env variables in composite run steps as well?
Thanks in advance!

That looks like a bug in the Actions runner to me, the documentation doesn’t mention any exceptions for composite actions (and I don’t think it’d make sense to have any exceptions like that).

You can set env per step, it’ll depend on your context if that simplifies things:

    - run: |
        echo "${INPUT_PARAM1}"
      shell: bash
      env:
        INPUT_PARAM1: ${{ inputs.param1 }}

@haya14busa,

Yes, according to the description in the docs, it seems should map the inputs as environment variables on all types of the actions.

However, compared with JavaScript action and Docker action, I don’t think it is matter that whether to map the inputs of composite action as environment variables.

  • Due to the ‘run’ scripts are directly defined in the metadata file (action.yml or action.yaml) of the composite action, these steps can directly access the inputs via the expression syntax (${{ inputs.input_id }}).

  • For the JavaScript action and Docker action, the scripts are not directly defined in the metadata file. In the scripts file (index.js) of JavaScript action, you need to use the function “core.getInput(‘input_id’)” to access or pass the inputs. And in the metadata file of Docker action, you need to use syntax ‘runs.args’ to pass the inputs to the scripts file (entrypoint.sh).
    On these two actions, using the automatically mapped environment variables indeed is very convenient when there are many inputs needed to be used in the scripts file.

But according to my test, I find:

  1. It seems does not support to directly use the environment variables of inputs in the metadata file of the actions.

  2. Currently, the environment variables of inputs only available on JavaScript action. On the Docker action, the inputs actually will not be mapped as environment variables in the container.

If your projects really need the feature that mapping inputs as environment variables on all types of the actions, I recommend that you can directly report a feature request here. That will allow you to directly interact with the appropriate engineering team, and make it more convenient for the engineering team to collect and categorize your suggestions.

Unfortunately that is not necessarily true, the documentation example explicitly shows how to run a script included in a composite action repository (the last step). In that case using ${{ inputs.id }} is not a suitable workaround.

Either way the behavior is contrary to documentation, so this is a matter for a bug report, not a feature request. I guess the actions/runner repository would be the right place for that?

@airtower-luna,

Yes, you’re right.
Maybe reporting a feature request is necessary.

1 Like

I wrote a bug report here: https://github.com/actions/runner/issues/665

1 Like