In my action.yml I defined an input:
name: 'test action' author: Param Thakkar description: 'test' inputs: test_var: description: 'A test variable' required: true runs: using: 'docker' image: 'Dockerfile' And in my workflow I passed the test_var:
name: CI on: [push] jobs: build: runs-on: ubuntu-latest steps: - name: Test the GH action uses: paramt/github-actions-playground@master with: test_var: "this is just a test" So there should be an environment variable that's created when the workflow runs, right? But when I run this short python script:
import os print(os.getenv('TEST_VAR')) print("It works!") exit(0) It prints:
None It works! I think that I have to pass the ENV variable through my Dockerfile... Right now my Dockerfile looks like this:
FROM python:latest # Add files to the image ADD entrypoint.py /entrypoint.py ADD requirements.txt /requirements.txt # Save ENV var in a temp file RUN $TEST_VAR > /temp_var # Install dependencies and make script executable RUN pip install -r requirements.txt RUN chmod +x entrypoint.py RUN echo "temp var: " RUN cat /temp_var # Run script with the ENV var ENTRYPOINT export TEST_VAR="$TEST_VAR"; /entrypoint.py But the variable isn't echoed and isn't passed to the pythons script either.. am I missing something? When I tried to set my $TEMP_VAR to a random piece of string, it is sent through to the Python script. Is this a mistake on my behalf or is the GitHub action not working as intended?
Here's the link to the test repo