Skip to content

Environment variable is not passed to the Python container action #134

@los0220

Description

@los0220

Thank you for this course (and other ones as well). I've learned a ton from them.

The issue

While doing the course, I noticed that the Python Container Action does not print the expected output:

As evidence, I provide the Python Container Action jobs from this repo as well as my fork:

As you can see, both the output and the annotation are:

 Hello, World! Time is 20:57:54 UTC.

Instead of the expected (like with the other container actions):

Hello, from a container github action 👋! Time is 20:57:54 UTC.

The fix

In the 06-authoring-actions/container-actions/python-container-action/action.yaml I replaced args with env to properly pass the input environmental variable to the container:

  env:
    INPUT_WHO_TO_GREET: ${{ inputs.who-to-greet }}
  # # only needed when you want to use the positional arguments (sys.argv) in the Python script
  # args:
  #   - ${{ inputs.who-to-greet }}

It appears that the INPUT_WHO_TO_GREET is not injected automatically by GitHub, as you mentioned.

In the 06-authoring-actions/container-actions/shell-container-action/action.yaml, you can see that the INPUT_WHO_TO_GREET is populated manually.

Thank you again for the great courses you make!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions