Is there a way to set non-secret environment variables in Github Actions on the Settings page?

Viewed 1333

As far as I know, there are two ways to set environment variables in Github Actions:

  • Hardcoding them into YAML file
  • Adding them as repository secrets on the settings page

Repository secrets page

But what if I don't want them to be secret? On the picture above, SERVER_PREFIX and ANALYTICS_ENABLED shouldn't be secret. Is there a way to set up env variables on the settings page and make them visible? In Travis we had that option.

2 Answers

There isn't an option to add non-secret ENV variables on GitHub page at now.

You can create workflow-scope ENV variables in workflow step.

env:
   SERVER_PREFIX: SOME_PREFIX

Then access by: ${{ env.SERVER_PREFIX }}

If you don't need to use them in the Action's YAML, just define your variables in a downloadable file and then use something like curl or wget to get them into your build environment.

For instance, I've done something similar for common CI files and now I've multiple projects running the same project building scripts, their local action is simply like: download an .sh file, run it.

If you need to set up variables in one of your build steps, to be used later by some other action, have a look at this (but I've never tried it myself).

Related