1
0
mirror of synced 2025-12-23 03:44:00 -05:00

Improve Actions docs on environment variables (#24246)

* Begin work on PR

* Modify intro section

* Add details of contexts

* More details added

* Fix broken link

* Fix liquid error

* More WiP

* More WiP changes

* add env var examples

* Finish initial draft of env vars article update

* Fix versioning in table

* Add remaining examples

* Another WiP tweak

* More WiP changes

* More WiP changes

* More WiP changes

* More WiP changes

* More WiP changes

* Add <nobr> to things

* Finish updating other articles

* test line breaks

* Remove previous test

* Update links to files now moved

* Rebplace nobr with spans

* Another test

* Remove the previous test

* Remove misleading note.

This note box was added by an OS contributor
https://github.com/github/docs/pull/9236/files
but is, at best, misleading.

Environment variables *can* be referenced directly within
a run command as  and do *not* have to be
referenced via the SHELL=/usr/local/bin/bash
ITERM_PROFILE=Default
COLORTERM=truecolor
XPC_FLAGS=0x0
NVM_INC=/Users/alistair/.nvm/versions/node/v12.8.0/include/node
TERM_PROGRAM_VERSION=3.4.14
GIT_PS1_SHOWUPSTREAM=verbose git
__CFBundleIdentifier=com.googlecode.iterm2
SSH_AUTH_SOCK=/var/folders/bh/jrv856xx31zfmhc60chqvxqw0000gn/T//ssh-7EnftFpl4aXq/agent.77591
GIT_PS1_SHOWDIRTYSTATE=1
TERM_SESSION_ID=w2t0p0:9F68FC35-8DB9-4051-A7C6-5E61A2C37694
HOMEBREW_AUTO_UPDATE_SECS=3600
RBENV_SHELL=bash
SSH_AGENT_PID=77592
ITERM_PREV_PS1=\[]133;D;$?]133;A\]\[\033[1;36m\]\w\[\033[0m\] \[\033[1;32m\]$(__git_ps1)\[\033[0m\]
\$ \[]133;B\]
GPG_TTY=/dev/ttys002
EDITOR=vi
ITERM_ORIG_PS1=\[\033[1;36m\]\w\[\033[0m\] \[\033[1;32m\]$(__git_ps1)\[\033[0m\]
\$
PWD=/Users/alistair/git-repos/docs-internal
LOGNAME=alistair
COMMAND_MODE=unix2003
NODENV_SHELL=bash
ITERM_SESSION_ID=w2t0p0:9F68FC35-8DB9-4051-A7C6-5E61A2C37694
HOME=/Users/alistair
LANG=en_GB.UTF-8
LS_COLORS=di=1;0;42:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35;40:*.rpm=90
TMPDIR=/var/folders/bh/jrv856xx31zfmhc60chqvxqw0000gn/T/
LC_TERMINAL=iTerm2
NVM_DIR=/Users/alistair/.nvm
TOKEN=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
TERM=xterm-256color
USER=alistair
COLORFGBG=15;0
LC_TERMINAL_VERSION=3.4.14
SHLVL=0
NVM_CD_FLAGS=
XPC_SERVICE_NAME=0
PS1=\[\033[1;36m\]\w\[\033[0m\] \[\033[1;32m\]$(__git_ps1)\[\033[0m\]
\$
PATH=/Users/alistair/git-repos/awssume/bin:/Users/alistair/git-repos/awssume/bin:/Users/alistair/.gem/ruby/2.7.0/bin:/Users/alistair/.rbenv/shims:/Users/alistair/.nodenv/shims:/Users/alistair/.nvm/versions/node/v12.8.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/alistair/git-repos/github/bin:/Users/alistair/programming:/Applications/VMware Fusion.app/Contents/Public:/usr/local/MacGPG2/bin:/Library/Apple/usr/bin:/Users/alistair/.node/bin:/Users/alistair/.nodenv/versions/14.13.0/
NVM_BIN=/Users/alistair/.nvm/versions/node/v12.8.0/bin
OLDPWD=/Users/alistair/git-repos/docs-internal/lib
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x2
TERM_PROGRAM=iTerm.app
_=/usr/bin/env context.

Confirmed by an answer to a question in the c2c-actions
channel https://github.slack.com/archives/CDJAC532T/p1642154921002900

* Update content/actions/learn-github-actions/environment-variables.md

Co-authored-by: Laura Coursen <lecoursen@github.com>

* Update content/actions/learn-github-actions/environment-variables.md

Co-authored-by: Laura Coursen <lecoursen@github.com>

* Update content/actions/learn-github-actions/environment-variables.md

Co-authored-by: Laura Coursen <lecoursen@github.com>

* Update content/actions/learn-github-actions/environment-variables.md

Co-authored-by: Laura Coursen <lecoursen@github.com>

* Update content/actions/learn-github-actions/environment-variables.md

Co-authored-by: Laura Coursen <lecoursen@github.com>

* Update content/actions/using-workflows/workflow-commands-for-github-actions.md

Co-authored-by: Laura Coursen <lecoursen@github.com>

* Update content/actions/learn-github-actions/environment-variables.md

Co-authored-by: Laura Coursen <lecoursen@github.com>

* Update content/actions/learn-github-actions/environment-variables.md

Co-authored-by: Laura Coursen <lecoursen@github.com>

* Update content/actions/learn-github-actions/environment-variables.md

Co-authored-by: Laura Coursen <lecoursen@github.com>

* Update content/actions/learn-github-actions/environment-variables.md

Co-authored-by: Laura Coursen <lecoursen@github.com>

* Make remaining review comment changes

Co-authored-by: Laura Coursen <lecoursen@github.com>
This commit is contained in:
hubwriter
2022-01-24 10:55:51 +00:00
committed by GitHub
parent 1cca6241cf
commit 2e5ea5cc83
3 changed files with 157 additions and 58 deletions

View File

@@ -307,7 +307,7 @@ The `STATE_processID` variable is then exclusively available to the cleanup scri
console.log("The running PID from the main action is: " + process.env.STATE_processID);
```
## Environment Files
## Environment files
During the execution of a workflow, the runner generates temporary files that can be used to perform certain actions. The path to these files are exposed via environment variables. You will need to use UTF-8 encoding when writing to these files to ensure proper processing of the commands. Multiple commands can be written to the same file, separated by newlines.
@@ -345,16 +345,10 @@ More detail about UTF-8 and PowerShell Core found on this great [Stack Overflow
## Setting an environment variable
``` bash
echo "{name}={value}" >> $GITHUB_ENV
echo "{environment_variable_name}={value}" >> $GITHUB_ENV
```
Creates or updates an environment variable for any steps running next in a job. The step that creates or updates the environment variable does not have access to the new value, but all subsequent steps in a job will have access. Environment variables are case-sensitive and you can include punctuation.
{% note %}
**Note:** Environment variables must be explicitly referenced using the [`env` context](/actions/reference/context-and-expression-syntax-for-github-actions#env-context) in expression syntax or through use of the `$GITHUB_ENV` file directly; environment variables are not implicitly available in shell commands.
{% endnote %}
You can make an environment variable available to any subsequent steps in a workflow job by defining or updating the environment variable and writing this to the `GITHUB_ENV` environment file. The step that creates or updates the environment variable does not have access to the new value, but all subsequent steps in a job will have access. The names of environment variables are case-sensitive, and you can include punctuation. For more information, see "[Environment variables](/actions/learn-github-actions/environment-variables)."
### Example