Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variable docs are inconsistent about GITHUB_ prefix #2693

Open
nex3 opened this issue Jan 8, 2021 · 6 comments · May be fixed by #5139
Open

Environment variable docs are inconsistent about GITHUB_ prefix #2693

nex3 opened this issue Jan 8, 2021 · 6 comments · May be fixed by #5139

Comments

@nex3
Copy link

@nex3 nex3 commented Jan 8, 2021

The Naming Conventions for Environment Variables documentation says:

Note: GitHub reserves the GITHUB_ environment variable prefix for internal use by GitHub. Setting an environment variable or secret with the GITHUB_ prefix will result in an error.

However, the example in jobs.<job_id>.steps[*].env sets a GITHUB_TOKEN environment variable. Which is correct?

@welcome
Copy link

@welcome welcome bot commented Jan 8, 2021

Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions bot added the triage label Jan 8, 2021
@github-actions github-actions bot added this to Triage in Docs team reviews Jan 8, 2021
@janiceilene
Copy link
Collaborator

@janiceilene janiceilene commented Jan 8, 2021

Thanks for opening an issue @nex3! I'll triage this for the team to take a look 👀

@hubwriter
Copy link
Contributor

@hubwriter hubwriter commented Mar 3, 2021

Hi @nex3 - Many thanks for raising this issue. 👍

Both of the pages you refer to are correct. The GITHUB_ name is reserved for use by GitHub. One such use is the GITHUB_TOKEN secret that allows you to reference an automatically created GitHub App installation access token in an Actions workflow, as shown in the example on the second page you refer to.

For more information about GITHUB_TOKEN see: https://docs.github.com/en/actions/reference/authentication-in-a-workflow

I'm going to close this issue, but thanks for checking this with us and, of course, if you'd like to discuss this more please get back to us.

EDIT: I was wrong about this. See my comment, with suggested changes, below: #2693 (comment)

@hubwriter hubwriter closed this Mar 3, 2021
Docs team reviews automation moved this from Content review needed to Done Mar 3, 2021
@nex3
Copy link
Author

@nex3 nex3 commented Mar 4, 2021

@hubwriter The issue is that the example in jobs.<job_id>.steps[*].env doesn't just reference the GITHUB_TOKEN secret, it actually sets an environment variable named GITHUB_TOKEN to the value of that secret, which is forbidden according to the environment variable docs.

@hubwriter
Copy link
Contributor

@hubwriter hubwriter commented Mar 4, 2021

@nex3 - Thanks for coming back about that. 👍🎖️
I think we need to change the env var name here: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsenv
I'll get that confirmed here and then we can ask for a community quick fix of that page.

@hubwriter hubwriter reopened this Mar 4, 2021
@github-actions github-actions bot added the triage label Mar 4, 2021
@hubwriter
Copy link
Contributor

@hubwriter hubwriter commented Mar 8, 2021

The text in the note box is incorrect. The GITHUB_TOKEN environment variable is often set in a workflow, and we have examples of this in the documentation. I've tested setting environment variables in workflows and using the GITHUB_ prefix does not result in an error. However, if you try to set a value to the default ones listed in the table here, the assignment does not work.

So we should remove the note on that page and replace it with a statement about trying to reuse the names of the default env vars.

i.e. in content/actions/reference/environment-variables.md, change:

{% note %}

**Note:** {% data variables.product.prodname_dotcom %} reserves the `GITHUB_` environment variable 
prefix for internal use by {% data variables.product.prodname_dotcom %}. 
Setting an environment variable or secret with the `GITHUB_` prefix will result in an error.

{% endnote %}

to a simple paragraph (rather than a note):

When you set a custom environment variable, you cannot use any of the default environment variable names 
listed above with the prefix `GITHUB_`. If you attempt to override the value of one of these default 
environment variables, the assignment is ignored.

@nex3 - Many thanks again for raising this, and for coming back when I incorrectly closed the issue. Kudos to you for bringing this to our attention.

@janiceilene janiceilene moved this from Done to Content review needed in Docs team reviews Mar 16, 2021
@janiceilene janiceilene moved this from Content review needed to Help wanted in Docs team reviews Mar 24, 2021
Sreelayavuyyuru added a commit to Sreelayavuyyuru/docs that referenced this issue Apr 7, 2021
I have done exactly what was mentioned in the issue. I am just getting started with open-source so I am sorry if I have done anything that is incorrect.
@Sreelayavuyyuru Sreelayavuyyuru linked a pull request that will close this issue Apr 7, 2021
3 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants