GitHub Actions can communicate with the runner machine using workflow commands. These commands allow you to set environment variables, output values, create debug messages, among other things. They are invoked by writing to stdout in a specific format.
Here's an example of a JavaScript action that uses workflow commands:
const core = require('@actions/core');
try {
// Set an output
core.setOutput('output1', 'some value');
// Set an environment variable
core.exportVariable('ENV_VAR', 'some value');
// Write a debug message
core.debug('This is a debug message');
// Write an error message
core.error('This is an error message');
// Fail the action
core.setFailed('This is a failure message');
} catch (error) {
core.setFailed(error.message);
}
In this script:
core.setOutput sets an output that can be used by other steps in the workflow.
core.exportVariable sets an environment variable that is available to all steps in the workflow.
core.debug writes a debug message to the log. Debug messages are only shown in the log if you set the ACTIONS_STEP_DEBUG secret to true in your repository.
core.error writes an error message to the log. This does not fail the action.
core.setFailed writes an error message to the log and fails the action. This causes the workflow to stop unless the continue-on-error option is set to true for this step.
Remember to replace 'output1', 'some value', 'ENV_VAR', 'This is a debug message', 'This is an error message', and 'This is a failure message' with the output name, output value, environment variable name, environment variable value, debug message, error message, and failure message that are appropriate for your action.
GitHub Actions can communicate with the runner machine using workflow commands. These commands allow you to set environment variables, output values, create debug messages, among other things. They are invoked by writing to
stdout
in a specific format.Here's an example of a JavaScript action that uses workflow commands:
In this script:
core.setOutput
sets an output that can be used by other steps in the workflow.core.exportVariable
sets an environment variable that is available to all steps in the workflow.core.debug
writes a debug message to the log. Debug messages are only shown in the log if you set theACTIONS_STEP_DEBUG
secret totrue
in your repository.core.error
writes an error message to the log. This does not fail the action.core.setFailed
writes an error message to the log and fails the action. This causes the workflow to stop unless thecontinue-on-error
option is set totrue
for this step.Remember to replace
'output1'
,'some value'
,'ENV_VAR'
,'This is a debug message'
,'This is an error message'
, and'This is a failure message'
with the output name, output value, environment variable name, environment variable value, debug message, error message, and failure message that are appropriate for your action.