Core functionality for reading action inputs with type conversion and validation, and setting outputs for downstream actions. This system enables actions to receive configuration from workflow files and communicate results to subsequent workflow steps.
Retrieves the value of an action input with optional validation and trimming.
/**
* Gets the value of an action input
* @param name - Name of the input to get
* @param options - Optional configuration for input retrieval
* @returns Input value as string, empty string if not defined
*/
function getInput(name: string, options?: InputOptions): string;
interface InputOptions {
/** Whether the input is required. If required and not present, will throw. Defaults to false */
required?: boolean;
/** Whether leading/trailing whitespace will be trimmed for the input. Defaults to true */
trimWhitespace?: boolean;
}Usage Examples:
import { getInput } from '@actions/core';
// Basic input retrieval
const inputValue = getInput('my-input');
// Required input with validation
const requiredInput = getInput('required-input', { required: true });
// Input without whitespace trimming
const rawInput = getInput('raw-input', { trimWhitespace: false });
// Input with default value
const inputWithDefault = getInput('optional-input') || 'default-value';Parses a boolean input following the YAML 1.2 "core schema" specification.
/**
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification
* Support boolean input list: `true | True | TRUE | false | False | FALSE`
* @param name - Name of the input to get
* @param options - Optional configuration for input retrieval
* @returns Boolean value parsed from input
* @throws TypeError if input doesn't match YAML 1.2 boolean specification
*/
function getBooleanInput(name: string, options?: InputOptions): boolean;Usage Examples:
import { getBooleanInput } from '@actions/core';
// Parse boolean input
const isEnabled = getBooleanInput('enabled');
// Required boolean input
const shouldDeploy = getBooleanInput('deploy', { required: true });
// Boolean input handles various cases: 'true', 'True', 'TRUE', 'false', 'False', 'FALSE'Retrieves a multiline input as an array of strings, with each line as a separate array element.
/**
* Gets the values of a multiline input. Each value is also trimmed.
* @param name - Name of the input to get
* @param options - Optional configuration for input retrieval
* @returns Array of strings, one per line, empty lines filtered out
*/
function getMultilineInput(name: string, options?: InputOptions): string[];Usage Examples:
import { getMultilineInput } from '@actions/core';
// Get multiline input as array
const files = getMultilineInput('files');
// Input "file1.txt\nfile2.txt\nfile3.txt" becomes ['file1.txt', 'file2.txt', 'file3.txt']
// Required multiline input
const requiredFiles = getMultilineInput('required-files', { required: true });
// Multiline input without trimming
const rawLines = getMultilineInput('raw-content', { trimWhitespace: false });
// Process each line
files.forEach((file, index) => {
console.log(`Processing file ${index + 1}: ${file}`);
});Sets an output value that can be used by other actions or workflow steps.
/**
* Sets the value of an action output
* @param name - Name of the output to set
* @param value - Value to store. Non-string values will be converted to a string via JSON.stringify
*/
function setOutput(name: string, value: any): void;Usage Examples:
import { setOutput } from '@actions/core';
// Set string output
setOutput('result', 'success');
// Set number output (automatically converted to string)
setOutput('count', 42);
// Set boolean output (automatically converted to string)
setOutput('completed', true);
// Set object output (automatically JSON stringified)
setOutput('metadata', {
version: '1.0.0',
timestamp: new Date().toISOString(),
files: ['app.js', 'config.json']
});
// Set array output
setOutput('processed-files', ['file1.txt', 'file2.txt']);Input functions can throw errors in specific conditions:
getInput() throws if required: true and input is not providedgetBooleanInput() throws TypeError if input doesn't match YAML 1.2 boolean valuesimport { getInput, getBooleanInput } from '@actions/core';
try {
const requiredInput = getInput('required-field', { required: true });
const booleanInput = getBooleanInput('flag-field');
} catch (error) {
console.error('Input validation failed:', error.message);
// Handle validation errors appropriately
}Action inputs are read from environment variables following the pattern:
INPUT_For example:
my-input reads from INPUT_MY_INPUT environment variablefile path reads from INPUT_FILE_PATH environment variableOutputs are written to:
GITHUB_OUTPUT file (preferred method for newer runners)The system automatically handles both methods for maximum compatibility.