Can workflow_dispatch inputs be enhanced to set INPUT_* environmental variables?


I noticed that INPUT_<UPPERCASEDINPUTNAME> environmental variables are not set for inputs defined in a workflow_dispatch trigger.

The blog post says you define them the same way as action inputs, but it doesn’t explicitly say that the environmental variables will be set. Since it uses the action inputs documentation as a reference though, I almost expected them to work the same way.

The documentation describes the format of the env variables for actions:

Here is a run showing it is not set

Either way it can be set manually through the echo"::set-env .... " syntax so it’s not a huge deal. I just wondered if this was something that was considered.


Yes, currently GitHub does not automatically create environment variables for the inputs of the ‘workflow_dispatch’ trigger.

If you want to use the inputs as environment variables in the workflow, you can set the inputs as the workflow global environment variables via the ‘env’ key.
For example:

        description: 'Log level'
        required: true
        default: 'warning'

  INPUT_LOG_LEVEL: ${{ github.event.inputs.log_Level }}

    runs-on: ubuntu-latest
      - name: Print input
        run: echo "The log level is $INPUT_LOG_LEVEL"

However, as mentioned in the docs, you also need to note that:

When more than one environment variable is defined with the same name, GitHub uses the most specific environment variable. For example, an environment variable defined in a step will override job and workflow variables with the same name, while the step executes. A variable defined for a job will override a workflow variable with the same name, while the job executes.

If your projects really need the feature that GitHub can automatically create environment variables for the inputs of the ‘workflow_dispatch’ trigger, 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.

1 Like

Thanks, I submitted the request.