Loading environment variables without inputs

I’m trying to get some variables/values into my Github Action, currently via environment variables. My Github Action is a docker image (pre-build).

So for example:

FROM alpine
COPY foo /foo
CMD ["/foo"]

I publish this image on a public registry and use it in my action.yml. (This part works!)

My action is doing templating (for files), so depending on what people come up with, the variables are not known to me right now and may change depending on use-case. So for example, I will read in a file, and it’ll replace {{ .FOO }} with whatever is in the environment variable FOO.

I realize that I can provide everything as an optional input (so this is not about passing environment variables to inputs), but I’d rather do something like:

      - name: my action
        uses: till/my-action@v1
          # this is an input, this works
          my-input: something
          # but I expect this to work also
          FOO: the-foo-value

And then my my-action can access FOO. I guess the docker run -e FOO=the-foo-value is not too far off, but is this stretching the system a little bit too much? Maybe I missed something or made it too complicated.

The step env will be added to docker run -e when run the docker action container. You could use the env variable in entrypoint.sh directly. $FOO could get the value.
An example entrypoint.sh:

#!/bin/sh -l

echo "Hello $1"
echo $FOO
echo ::set-output name=time::$time

The input variables of an action will be converted to environment variables with INPUT_ prefix.


Thank you for responding!

And odd, I believe I tried this before but I don’t want to rule out an error on my part. I’ll try this again!

Sure, if you meet any question, feel free to contact me here.