Skip to content

Commit 937a86c

Browse files
committed
Actions: Add echo workflow command
Fixes #7868
1 parent b9dc041 commit 937a86c

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

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

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ The following table shows which toolkit functions are available within a workflo
6868
| ----------------- | ------------- |
6969
| `core.addPath` | Accessible using environment file `GITHUB_PATH` |
7070
| `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 %}
7272
| `core.error` | `error` |
7373
| `core.endGroup` | `endgroup` |
7474
| `core.exportVariable` | Accessible using environment file `GITHUB_ENV` |
7575
| `core.getInput` | Accessible using environment variable `INPUT_{NAME}` |
7676
| `core.getState` | Accessible using environment variable `STATE_{NAME}` |
7777
| `core.isDebug` | Accessible using environment variable `RUNNER_DEBUG` |
7878
| `core.saveState` | `save-state` |
79+
| `core.setCommandEcho` | `echo` |
7980
| `core.setFailed` | Used as a shortcut for `::error` and `exit 1` |
8081
| `core.setOutput` | `set-output` |
8182
| `core.setSecret` | `add-mask` |
@@ -246,6 +247,44 @@ jobs:
246247
247248
{% endraw %}
248249
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+
249288
## Sending values to the pre and post actions
250289
251290
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

Comments
 (0)