Skip to content

Commit f051853

Browse files
authored
Merge pull request #86 from github/repo-sync
repo sync
2 parents 698a3b9 + 677a533 commit f051853

File tree

3 files changed

+83
-9
lines changed

3 files changed

+83
-9
lines changed

content/actions/creating-actions/metadata-syntax-for-github-actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ For more information, see "[`github context`](/actions/reference/context-and-exp
244244

245245
##### **`runs.steps.env`**
246246

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.
248248

249249
##### **`runs.steps.working-directory`**
250250

content/actions/reference/environment-variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ steps:
3030
Last_Name: Octocat
3131
```
3232
33-
You can also use the `set-env` workflow command to 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)."
3434

3535
### Default environment variables
3636

content/actions/reference/workflow-commands-for-github-actions.md

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ versions:
2121

2222
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.
2323

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 %}
2427
Workflow commands use the `echo` command in a specific format.
28+
{% endif %}
2529

2630
``` bash
2731
echo "::workflow-command parameter1={data},parameter2={data}::{command value}"
@@ -41,30 +45,31 @@ echo "::workflow-command parameter1={data},parameter2={data}::{command value}"
4145

4246
### Using workflow commands to access toolkit functions
4347

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:
4549

4650
```javascript
47-
core.exportVariable('SELECTED_COLOR', 'green');
51+
core.setOutput('SELECTED_COLOR', 'green');
4852
```
4953

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:
5155

5256
``` yaml
5357
- name: Set selected color
54-
run: echo '::set-env name=SELECTED_COLOR::green'
58+
run: echo '::set-output name=SELECTED_COLOR::green'
59+
id: random-color-generator
5560
- name: Get color
56-
run: echo 'The selected color is' $SELECTED_COLOR
61+
run: echo 'The selected color is' ${steps.random-color-generator.outputs.SELECTED_COLOR}
5762
```
5863
5964
The following table shows which toolkit functions are available within a workflow:
6065
6166
| Toolkit function| Equivalent workflow command|
6267
| ------------- | ------------- |
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 %} |
6469
| `core.debug` | `debug` |
6570
| `core.error` | `error` |
6671
| `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 %} |
6873
| `core.getInput` | Accessible using environment variable `INPUT_{NAME}` |
6974
| `core.getState` | Accessible using environment variable `STATE_{NAME}` |
7075
| `core.isDebug` | Accessible using environment variable `RUNNER_DEBUG` |
@@ -75,6 +80,7 @@ The following table shows which toolkit functions are available within a workflo
7580
| `core.startGroup` | `group` |
7681
| `core.warning` | `warning file` |
7782

83+
{% if currentVersion ver_lt "enterprise-server@2.23" %}
7884
### Setting an environment variable
7985

8086
`::set-env name={name}::{value}`
@@ -86,6 +92,7 @@ Creates or updates an environment variable for any actions running next in a job
8692
``` bash
8793
echo "::set-env name=action_state::yellow"
8894
```
95+
{% endif %}
8996

9097
### Setting an output parameter
9198

@@ -101,6 +108,7 @@ Optionally, you can also declare output parameters in an action's metadata file.
101108
echo "::set-output name=action_fruit::strawberry"
102109
```
103110

111+
{% if currentVersion ver_lt "enterprise-server@2.23" %}
104112
### Adding a system path
105113

106114
`::add-path::{path}`
@@ -112,6 +120,7 @@ Prepends a directory to the system `PATH` variable for all subsequent actions in
112120
``` bash
113121
echo "::add-path::/path/to/dir"
114122
```
123+
{% endif %}
115124

116125
### Setting a debug message
117126

@@ -213,3 +222,68 @@ The `STATE_processID` variable is then exclusively available to the cleanup scri
213222
``` javascript
214223
console.log("The running PID from the main action is: " + process.env.STATE_processID);
215224
```
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:
234+
235+
```
236+
steps:
237+
- run: echo "mypath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
238+
```
239+
240+
{% endwarning %}
241+
242+
### Setting an environment variable
243+
244+
`echo "{name}={value}" >> $GITHUB_ENV`
245+
246+
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.
283+
284+
#### Example
285+
286+
``` bash
287+
echo "/path/to/dir" >> $GITHUB_PATH
288+
```
289+
{% endif %}

0 commit comments

Comments
 (0)