docs icon indicating copy to clipboard operation
docs copied to clipboard

Mention that `GITHUB_*` and `RUNNER_*` can't be set using `GITHUB_ENV` (but that `CI` can be)

Open jsoref opened this issue 2 years ago • 8 comments

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/learn-github-actions/environment-variables

What part(s) of the article would you like to see updated?

The default environment variables that GitHub sets are available to every step in a workflow.

We strongly recommend that actions use environment variables to access the filesystem rather than using hardcoded file paths. GitHub sets environment variables for actions to use in all runner environments.

My understanding is that one can't set GITHUB_* / RUNNER_* variables using GITHUB_ENV. However, CI can be set using it.

There should be some documentation about this detail.

@aeisenberg mentioned the GITHUB_ part in: https://github.com/github/codeql-action/issues/796#issuecomment-1018727859

And I'm pretty sure I've seen it somewhere, but I can't recall where, and I certainly can't find it.

The other place one might expect to see it is here: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable

And it isn't mentioned there either.

Additional information

https://github.com/jsoref/actions-env-0/blob/513b30f1654f0525fc15959c67eb1618d3de7a9b/.github/workflows/env.ymlwhih https://github.com/jsoref/actions-env-0/runs/7753662690?check_suite_focus=true


2022-08-09T19:31:39.4209486Z ##[group]Run grep CI $GITHUB_ENV || echo CI=0 >> $GITHUB_ENV;
2022-08-09T19:31:39.4210046Z [36;1mgrep CI $GITHUB_ENV || echo CI=0 >> $GITHUB_ENV;[0m
2022-08-09T19:31:39.4210484Z [36;1mperl -pi -e 's/CI=.*/CI=test/' $GITHUB_ENV;[0m
2022-08-09T19:31:39.4210849Z [36;1mgrep CI $GITHUB_ENV[0m
2022-08-09T19:31:39.4273418Z shell: /usr/bin/bash -e {0}
2022-08-09T19:31:39.4273759Z ##[endgroup]
2022-08-09T19:31:39.4417914Z CI=test
2022-08-09T19:31:39.4461857Z ##[group]Run echo $CI
2022-08-09T19:31:39.4462243Z [36;1mecho $CI[0m
2022-08-09T19:31:39.4522487Z shell: /usr/bin/bash -e {0}
2022-08-09T19:31:39.4522841Z env:
2022-08-09T19:31:39.4523091Z   CI: test
2022-08-09T19:31:39.4523368Z ##[endgroup]
2022-08-09T19:31:39.4866098Z test

jsoref avatar Aug 09 '22 19:08 jsoref

:wave: @jsoref Thanks so much for opening an issue! I'll triage this for the team to take a look :eyes:

cmwilson21 avatar Aug 10 '22 16:08 cmwilson21

Thanks for opening an issue! We've triaged this issue for technical review by a subject matter expert :eyes:

github-actions[bot] avatar Aug 22 '22 07:08 github-actions[bot]

This seems like a reasonable addition, although I'm not sure if being able to re-set CI is an intentional (i.e. not a bug) behavior.

We should advise that it is not possible or advisable to re-set any of the default environment variables listed in https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables.

Also mentioning the same in https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable is good place too.

Adding a reusable to both locations would be the best approach. Feel free to open a PR 🚀

lucascosti avatar Aug 23 '22 01:08 lucascosti

I don't suppose I could get you to investigate the CI side? I'm happy to make the PR as is, but I really do file quite a few bugs, and I'm currently stuck on quite a few PRs and don't want to be seen as pestering (I really need someone to go through a whole actions org ... -- https://github.com/pulls?q=is%3Aopen+is%3Apr+author%3Ajsoref+archived%3Afalse+org%3Aactions)

jsoref avatar Aug 23 '22 01:08 jsoref

@lucascosti ?

jsoref avatar Jan 20 '23 16:01 jsoref

delet all my work plz i dont want

في جمعة، 20 يناير، 2566 BE في 8:35 م، كتب Josh Soref < @.***>:

@lucascosti https://github.com/lucascosti ?

— Reply to this email directly, view it on GitHub https://github.com/github/docs/issues/19626#issuecomment-1398636292, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUXWYV6DJA3NYVOEYDGVLOTWTK5ELANCNFSM56B7BKTQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ghost avatar Jan 20 '23 16:01 ghost

Sorry, bot closed this prematurely.

I didn't get any response from engineering on the question of being able to set CI variable, so at this point I'd assume that it's deliberate.

The content plan in https://github.com/github/docs/issues/19626#issuecomment-1223390491 is should be still applicable for anyone wanting to contribute 🙂

lucascosti avatar Jan 23 '23 00:01 lucascosti

Sigh, lemme see if I can schedule this...

jsoref avatar Aug 10 '23 16:08 jsoref

Wait, this was fixed. I fixed it! https://github.com/github/docs/pull/20069#issuecomment-1638268279

jsoref avatar Aug 10 '23 23:08 jsoref