When I invoke an action I wrote with an input, the input doesn't seem to be visible to the action

I’m in the process of writing my own action, contained in this repo: https://github.com/enarx/nightly-features

As part of the action’s definition, I expect some input (I’ve named it allowed_features). From Github Actions’ documentation, this should be accessible via the environment variable INPUT_ALLOWED_FEATURES when specified by a calling workflow.

However, this doesn’t seem to be working for me. I’ve written a workflow that invokes this action here. It provides the input, as far as I can tell, correctly; however, when I run that workflow, the action I wrote doesn’t seem to be able to read from the expected environment variable. You can see that demonstrated in this workflow run: https://github.com/mbestavros/enarx/runs/1009733602?check_suite_focus=true

I’ve dumped the environment variables into the log from the called action, and it doesn’t deem to have the expected INPUT_ALLOWED_FEATURES among them.

Does anyone have any pointers as to how I’m going wrong? I’ve looked at other examples, and everything I’ve looked at suggests I’m doing things correctly.

Thanks in advance!

For testing purposes, could you add this to your action.yml and see what it prints?

    - run: |
        echo "inputs.allowed_features: ${{ inputs.allowed_features }}"
      shell: bash

@Simran-B Fascinating… inputs.allowed_features seems to work! But env.INPUT_ALLOWED_FEATURES is still empty.

How would one access inputs from the shell (or Python)?

Hi @mbestavros,

In action.yaml, you can use ‘set-env’ to add ${{ inputs.allowed_features }} to env context, then you can get it from the shell.

    - run: echo "::set-env name=INPUT_ALLOWED_FEATURES::${{ inputs.allowed_features }}"
      shell: bash

I forked your action repo and confirmed it works(comment some shell script), please check it for your reference.




@Simran-B @weide-zhou Thanks so much to both of you for your help! It works like a charm now :slight_smile:

It would be helpful if the Actions documentation was updated with this alternative. I had no idea of this approach from just reading; having this called out would be helpful for future Actions developers.

1 Like

Glad to support :wink:! @mbestavros

According to the policy, you can raise a feedback ticket in below link to ask for doc update, github product manager will take a review and help to check, thanks.