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/learn-github-actions/workflow-commands-for-github-actions.md
+40-1Lines changed: 40 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -68,14 +68,15 @@ The following table shows which toolkit functions are available within a workflo
68
68
| ----------------- | ------------- |
69
69
| `core.addPath` | Accessible using environment file `GITHUB_PATH` |
70
70
| `core.debug` | `debug` |{% ifversion fpt or ghes > 3.2 or ghae-issue-4929 or ghec %}
71
-
| `core.notice` | `notice` |{% endif %}
71
+
| `core.notice` | `notice` |{% endif %}
72
72
| `core.error` | `error` |
73
73
| `core.endGroup` | `endgroup` |
74
74
| `core.exportVariable` | Accessible using environment file `GITHUB_ENV` |
75
75
| `core.getInput` | Accessible using environment variable `INPUT_{NAME}` |
76
76
| `core.getState` | Accessible using environment variable `STATE_{NAME}` |
77
77
| `core.isDebug` | Accessible using environment variable `RUNNER_DEBUG` |
78
78
| `core.saveState` | `save-state` |
79
+
| `core.setCommandEcho` | `echo` |
79
80
| `core.setFailed` | Used as a shortcut for `::error` and `exit 1` |
80
81
| `core.setOutput` | `set-output` |
81
82
| `core.setSecret` | `add-mask` |
@@ -246,6 +247,44 @@ jobs:
246
247
247
248
{% endraw %}
248
249
250
+
## Echoing command outputs
251
+
252
+
```
253
+
::echo::on
254
+
::echo::off
255
+
```
256
+
257
+
The `echo` command lets you enable or disable echoing of workflow commands. For example, if you use the `set-output` command in a workflow, it sets an output parameter but the workflow run log does not show the command itself. If you enable command echoing, then the log shows the command output, like `::set-output name={name}::{value}`.
258
+
259
+
Command echoing is disabled by default. A workflow command is echoed if any error occurs processing the command, however.
260
+
261
+
You can enable command echoing globally by turning on step debug logging (`ACTIONS_STEP_DEBUG` secret). For more information, see "[Enabling debug logging](/actions/managing-workflow-runs/enabling-debug-logging)". In contrast, the `echo` command lets you enable command echoing more granular.
262
+
263
+
The commands `debug`, `notice`, `warning`, and `error` do not support echoing because they print messages to the log anyway.
264
+
265
+
### Example toggling command echoing
266
+
267
+
```yaml
268
+
jobs:
269
+
workflow-command-job:
270
+
runs-on: ubuntu-latest
271
+
steps:
272
+
- name: toggle workflow command echoing
273
+
run: |
274
+
echo '::set-output name=action_echo::disabled'
275
+
echo '::echo::on'
276
+
echo '::set-output name=action_echo::enabled'
277
+
echo '::echo::off'
278
+
echo '::set-output name=action_echo::disabled'
279
+
```
280
+
281
+
Turns command echoing on and off and sets an output parameter in both states. Only the second `set-output` and `echo` commands will show in the log because command echoing is enabled when they are run. Command echoing is disabled when all other commands are run and they are thus not printed. The output parameter is set in all cases.
282
+
283
+
```
284
+
::set-output name=action_echo::enabled
285
+
::echo::off
286
+
```
287
+
249
288
## Sending values to the pre and post actions
250
289
251
290
You can use the `save-state` command to create environment variables for sharing with your workflow's `pre:` or `post:` actions. For example, you can create a file with the `pre:` action, pass the file location to the `main:` action, and then use the `post:` action to delete the file. Alternatively, you could create a file with the `main:` action, pass the file location to the `post:` action, and also use the `post:` action to delete the file.
0 commit comments