mirror of https://github.com/actions/toolkit
Create commands.md (#105)
* Create commands.md * Feedback * Update action-debugging.mdpull/128/head
parent
b3bf422391
commit
2c6d31be8f
|
@ -18,7 +18,7 @@ All actions ran while this secret is enabled contain additional diagnostic log f
|
||||||
## Step Debug Logs
|
## Step Debug Logs
|
||||||
Step debug logs increase the verbosity of a job's logs during and after a job's execution to assist with troubleshooting.
|
Step debug logs increase the verbosity of a job's logs during and after a job's execution to assist with troubleshooting.
|
||||||
|
|
||||||
Additional log events with the prefix `##[debug]` will now also appear in the job's logs.
|
Additional log events with the prefix `::debug::` will now also appear in the job's logs.
|
||||||
|
|
||||||
### How to Access Step Debug Logs
|
### How to Access Step Debug Logs
|
||||||
This flag can be enabled by [setting the secret](https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables) `ACTIONS_STEP_DEBUG` to `true`.
|
This flag can be enabled by [setting the secret](https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables) `ACTIONS_STEP_DEBUG` to `true`.
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
# :: Commands
|
||||||
|
|
||||||
|
The [core toolkit package](https://github.com/actions/toolkit/tree/master/packages/core) offers a number of convenience functions for
|
||||||
|
setting results, logging, registering secrets and exporting variables across actions. Sometimes, however, its useful to be able to do
|
||||||
|
these things in a script or other tool.
|
||||||
|
|
||||||
|
To allow this, we provide a special `::` syntax which, if logged to `stdout`, will allow the runner to perform special behavior on
|
||||||
|
your commands. The following commands are all supported:
|
||||||
|
|
||||||
|
### Set an environment variable
|
||||||
|
|
||||||
|
To set an environment variable, use `::set-env`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
echo ::set-env name=FOO::BAR
|
||||||
|
```
|
||||||
|
|
||||||
|
Running `$FOO` in a future step will now return `BAR`
|
||||||
|
|
||||||
|
### PATH Manipulation
|
||||||
|
|
||||||
|
To prepend a string to PATH, use `::addPath`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
echo ::add-path::BAR
|
||||||
|
```
|
||||||
|
|
||||||
|
Running `$PATH` in a future step will now return `BAR:{Previous Path}`;
|
||||||
|
|
||||||
|
### Set outputs
|
||||||
|
|
||||||
|
To set an output for the step, use `::set-output`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
echo ::set-output name=FOO::BAR
|
||||||
|
```
|
||||||
|
|
||||||
|
Running `steps.[step-id].outputs.FOO` in your Yaml will now give you `BAR`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Set the value
|
||||||
|
id: step_one
|
||||||
|
run: echo ::set-output name=FOO::BAR
|
||||||
|
- name: Use it
|
||||||
|
run: echo ${{ steps.step_one.outputs.FOO }}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Masking Values in Logs
|
||||||
|
|
||||||
|
To mask a value in the logs, use `::add-mask`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
echo ::add-mask::BAR
|
||||||
|
```
|
||||||
|
|
||||||
|
Now, future logs containing BAR will be masked. E.g. running `echo "Hello FOO BAR World"` will now print `Hello FOO **** World`.
|
||||||
|
|
||||||
|
CAUTION: Do **not** mask short values if you can avoid it, it could render your output unreadable (and future steps' output as well).
|
||||||
|
For example, if you mask the letter `l`, running `echo "Hello FOO BAR World"` will now print `He*********o FOO BAR Wor****d`
|
||||||
|
|
||||||
|
### Log Level
|
||||||
|
|
||||||
|
Finally, there are several commands to emit different levels of log output:
|
||||||
|
|
||||||
|
| log level | example usage |
|
||||||
|
|---|---|
|
||||||
|
| [debug](https://github.com/actions/toolkit/blob/master/docs/action-debugging.md) | `echo ::debug::My debug message` |
|
||||||
|
| warning | `echo ::warning::My warning message` |
|
||||||
|
| error | `echo ::error::My error message` |
|
Loading…
Reference in New Issue