You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/actions/creating-actions/metadata-syntax-for-github-actions.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -244,7 +244,7 @@ For more information, see "[`github context`](/actions/reference/context-and-exp
244
244
245
245
##### **`runs.steps.env`**
246
246
247
-
**Optional** Sets a `map` of environment variables for only that step. If you want to modify the environment variable stored in the workflow, use `echo "::set-env name={name}::{value}"` in a composite run step.
247
+
**Optional** Sets a `map` of environment variables for only that step. If you want to modify the environment variable stored in the workflow, use {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}`echo "{name}={value}" >> $GITHUB_ENV`{% else %}`echo "::set-env name={name}::{value}"`{% endif %} in a composite run step.
Copy file name to clipboardExpand all lines: content/actions/reference/environment-variables.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ steps:
30
30
Last_Name: Octocat
31
31
```
32
32
33
-
You can also use the `set-env` workflow commandto set an environment variable that the following steps in a workflow can use. The `set-env` command can be used directly by an action or as a shell command in a workflow file using the `run` keyword. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/reference/workflow-commands-for-github-actions/#setting-an-environment-variable)."
33
+
You can also use the {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}`GITHUB_ENV` environment file{% else %} `set-env` workflow command{% endif %} to set an environment variable that the following steps in a workflow can use. The {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}environment file{% else %} `set-env` command{% endif %} can be used directly by an action or as a shell command in a workflow file using the `run` keyword. For more information, see "[Workflow commands for {% data variables.product.prodname_actions %}](/actions/reference/workflow-commands-for-github-actions/#setting-an-environment-variable)."
Copy file name to clipboardExpand all lines: content/actions/reference/workflow-commands-for-github-actions.md
+81-7Lines changed: 81 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,11 @@ versions:
21
21
22
22
Actions can communicate with the runner machine to set environment variables, output values used by other actions, add debug messages to the output logs, and other tasks.
23
23
24
+
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}
25
+
Most workflow commands use the `echo` command in a specific format, while others are invoked by writing to a file. For more information, see ["Environment files".](#environment-files)
26
+
{% else %}
24
27
Workflow commands use the `echo` command in a specific format.
### Using workflow commands to access toolkit functions
43
47
44
-
The [actions/toolkit](https://github.com/actions/toolkit) includes a number of functions that can be executed as workflow commands. Use the `::` syntax to run the workflow commands within your YAML file; these commands are then sent to the runner over `stdout`. For example, instead of using code to set an environment variable, as below:
48
+
The [actions/toolkit](https://github.com/actions/toolkit) includes a number of functions that can be executed as workflow commands. Use the `::` syntax to run the workflow commands within your YAML file; these commands are then sent to the runner over `stdout`. For example, instead of using code to set an output, as below:
45
49
46
50
```javascript
47
-
core.exportVariable('SELECTED_COLOR', 'green');
51
+
core.setOutput('SELECTED_COLOR', 'green');
48
52
```
49
53
50
-
You can use the `set-env` command in your workflow to set the same value:
54
+
You can use the `set-output` command in your workflow to set the same value:
run: echo 'The selected color is' ${steps.random-color-generator.outputs.SELECTED_COLOR}
57
62
```
58
63
59
64
The following table shows which toolkit functions are available within a workflow:
60
65
61
66
| Toolkit function| Equivalent workflow command|
62
67
| ------------- | ------------- |
63
-
| `core.addPath` | `add-path` |
68
+
| `core.addPath` | {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}Accessible using environment file `GITHUB_PATH`{% else %} `add-path` {% endif %} |
64
69
| `core.debug` | `debug` |
65
70
| `core.error` | `error` |
66
71
| `core.endGroup` | `endgroup` |
67
-
| `core.exportVariable` | `set-env` |
72
+
| `core.exportVariable` | {% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}Accessible using environment file `GITHUB_ENV`{% else %} `set-env` {% endif %} |
68
73
| `core.getInput` | Accessible using environment variable `INPUT_{NAME}` |
69
74
| `core.getState` | Accessible using environment variable `STATE_{NAME}` |
70
75
| `core.isDebug` | Accessible using environment variable `RUNNER_DEBUG` |
@@ -75,6 +80,7 @@ The following table shows which toolkit functions are available within a workflo
75
80
| `core.startGroup` | `group` |
76
81
| `core.warning` | `warning file` |
77
82
83
+
{% if currentVersion ver_lt "enterprise-server@2.23" %}
78
84
### Setting an environment variable
79
85
80
86
`::set-env name={name}::{value}`
@@ -86,6 +92,7 @@ Creates or updates an environment variable for any actions running next in a job
86
92
``` bash
87
93
echo "::set-env name=action_state::yellow"
88
94
```
95
+
{% endif %}
89
96
90
97
### Setting an output parameter
91
98
@@ -101,6 +108,7 @@ Optionally, you can also declare output parameters in an action's metadata file.
101
108
echo "::set-output name=action_fruit::strawberry"
102
109
```
103
110
111
+
{% if currentVersion ver_lt "enterprise-server@2.23" %}
104
112
### Adding a system path
105
113
106
114
`::add-path::{path}`
@@ -112,6 +120,7 @@ Prepends a directory to the system `PATH` variable for all subsequent actions in
112
120
``` bash
113
121
echo "::add-path::/path/to/dir"
114
122
```
123
+
{% endif %}
115
124
116
125
### Setting a debug message
117
126
@@ -213,3 +222,68 @@ The `STATE_processID` variable is then exclusively available to the cleanup scri
213
222
``` javascript
214
223
console.log("The running PID from the main action is: " + process.env.STATE_processID);
215
224
```
225
+
226
+
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.22" %}
227
+
## Environment Files
228
+
229
+
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.
230
+
231
+
{% warning %}
232
+
233
+
**Warning:** Powershell does not use UTF-8 by default. Make sure you write files using the correct encoding. For example, you need to set UTF-8 encoding when you set the path:
Creates or updates an environment variable for any actions running next in a job. The action that creates or updates the environment variable does not have access to the new value, but all subsequent actions in a job will have access. Environment variables are case-sensitive and you can include punctuation.
247
+
248
+
#### Example
249
+
250
+
```bash
251
+
echo "action_state=yellow" >> $GITHUB_ENV
252
+
```
253
+
254
+
Running `$action_state` in a future step will now return `yellow`
255
+
256
+
#### Multline strings
257
+
For multiline strings, you may use a delimeter with the following syntax.
258
+
259
+
```
260
+
{name}<<{delimeter}
261
+
{value}
262
+
{delimeter}
263
+
```
264
+
265
+
#### Example
266
+
In this example, we use `EOF` as a delimiter and set the `JSON_RESPONSE` environment variable to the value of the curl response.
267
+
```
268
+
steps:
269
+
- name: Set the value
270
+
id: step_one
271
+
run: |
272
+
echo 'JSON_RESPONSE<<EOF' >> $GITHUB_ENV
273
+
curl https://httpbin.org/json >> $GITHUB_ENV
274
+
echo 'EOF' >> $GITHUB_ENV
275
+
```
276
+
277
+
278
+
### Adding a system path
279
+
280
+
`echo "{path}" >> $GITHUB_PATH`
281
+
282
+
Prepends a directory to the system `PATH` variable for all subsequent actions in the current job. The currently running action cannot access the new path variable.
0 commit comments