Note: GitHub-hosted runners are not currently supported on GitHub Enterprise Server. You can see more information about planned future support on the GitHub public roadmap.
About workflow commands
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.
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."
Example
echo "::workflow-command parameter1={data},parameter2={data}::{command value}"Write-Output "::workflow-command parameter1={data},parameter2={data}::{command value}"Note: Workflow command and parameter names are not case-sensitive.
Warning: If you are using Command Prompt, omit double quote characters (") when using workflow commands.
Using workflow commands to access toolkit functions
The 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:
core.setOutput('SELECTED_COLOR', 'green');Example: Setting a value
You can use the set-output command in your workflow to set the same value:
- name: Set selected color
run: echo '::set-output name=SELECTED_COLOR::green'
id: random-color-generator
- name: Get color
run: echo "The selected color is ${{ steps.random-color-generator.outputs.SELECTED_COLOR }}" - name: Set selected color
run: Write-Output "::set-output name=SELECTED_COLOR::green"
id: random-color-generator
- name: Get color
run: Write-Output "The selected color is ${{ steps.random-color-generator.outputs.SELECTED_COLOR }}"The following table shows which toolkit functions are available within a workflow:
| Toolkit function | Equivalent workflow command |
|---|---|
core.addPath | Accessible using environment file GITHUB_PATH |
core.debug | debug |
core.notice | notice |
core.error | error |
core.endGroup | endgroup |
core.exportVariable | Accessible using environment file GITHUB_ENV |
core.getInput | Accessible using environment variable INPUT_{NAME} |
core.getState | Accessible using environment variable STATE_{NAME} |
core.isDebug | Accessible using environment variable RUNNER_DEBUG |
core.saveState | save-state |
core.setCommandEcho | echo |
core.setFailed | Used as a shortcut for ::error and exit 1 |
core.setOutput | set-output |
core.setSecret | add-mask |
core.startGroup | group |
core.warning | warning |
Setting an output parameter
Sets an action's output parameter.
::set-output name={name}::{value}Optionally, you can also declare output parameters in an action's metadata file. For more information, see "Metadata syntax for GitHub Actions."
You can escape multiline strings for setting an output parameter by creating an environment variable and using it in a workflow command. For more information, see "Setting an environment variable."
Example: Setting an output parameter
echo "::set-output name=action_fruit::strawberry"Write-Output "::set-output name=action_fruit::strawberry"Setting a debug message
Prints a debug message to the log. You must create a secret named ACTIONS_STEP_DEBUG with the value true to see the debug messages set by this command in the log. For more information, see "Enabling debug logging."
::debug::{message}Example: Setting a debug message
echo "::debug::Set the Octocat variable"Write-Output "::debug::Set the Octocat variable"Setting a notice message
Creates a notice message and prints the message to the log. This message will create an annotation, which can associate the message with a particular file in your repository. Optionally, your message can specify a position within the file.
::notice file={name},line={line},endLine={endLine},title={title}::{message}| Parameter | Value |
|---|---|
title | Custom title |
file | Filename |
col | Column number, starting at 1 |
endColumn | End column number |
line | Line number, starting at 1 |
endLine | End line number |
Example: Setting a notice message
echo "::notice file=app.js,line=1,col=5,endColumn=7::Missing semicolon"Write-Output "::notice file=app.js,line=1,col=5,endColumn=7::Missing semicolon"Setting a warning message
Creates a warning message and prints the message to the log. This message will create an annotation, which can associate the message with a particular file in your repository. Optionally, your message can specify a position within the file.
::warning file={name},line={line},endLine={endLine},title={title}::{message}| Parameter | Value |
|---|---|
title | Custom title |
file | Filename |
col | Column number, starting at 1 |
endColumn | End column number |
line | Line number, starting at 1 |
endLine | End line number |
Example: Setting a warning message
echo