or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

environment-state.mdindex.mdinput-output.mdjob-summaries.mdlogging-annotations.mdoidc-tokens.mdoutput-grouping.mdpath-utilities.mdplatform-detection.md
tile.json

index.mddocs/

@actions/core

@actions/core provides essential core functions for GitHub Actions, enabling action developers to interact with the GitHub Actions runtime environment. It offers comprehensive functionality for input/output handling, environment variable management, logging capabilities, secret masking, exit code management, OIDC token generation, filesystem path utilities, platform detection helpers, job summary generation, and annotation systems.

Package Information

  • Package Name: @actions/core
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @actions/core

Core Imports

import * as core from '@actions/core';

For CommonJS:

const core = require('@actions/core');

You can also import specific functions:

import { 
  getInput, 
  setOutput, 
  setFailed, 
  info, 
  warning, 
  error, 
  exportVariable,
  setSecret 
} from '@actions/core';

Basic Usage

import * as core from '@actions/core';

try {
  // Get action inputs
  const name = core.getInput('name', { required: true });
  const count = core.getInput('count') || '1';
  
  // Log information
  core.info(`Processing ${name} with count ${count}`);
  
  // Perform action logic
  const result = processData(name, parseInt(count));
  
  // Set outputs
  core.setOutput('result', result);
  core.setOutput('success', 'true');
  
} catch (error) {
  // Handle errors and set action as failed
  core.setFailed(`Action failed with error: ${error.message}`);
}

Architecture

@actions/core is built around several key components:

  • Input/Output System: Type-safe methods for reading action inputs and setting outputs with built-in validation
  • Logging Framework: Multiple severity levels (debug, info, warning, error) with structured output formatting and annotation support
  • Environment Management: Cross-step communication via environment variables with proper masking for secrets
  • Command Interface: Low-level communication with GitHub Actions runner via specially formatted commands
  • Job Summaries: Rich HTML content generation system for creating detailed workflow summaries
  • Platform Utilities: Cross-platform path manipulation and system information detection
  • OIDC Integration: Secure token generation for authenticating with third-party services

Capabilities

Input and Output Handling

Core functionality for reading action inputs with type conversion and validation, and setting outputs for downstream actions.

function getInput(name: string, options?: InputOptions): string;
function getBooleanInput(name: string, options?: InputOptions): boolean;
function getMultilineInput(name: string, options?: InputOptions): string[];
function setOutput(name: string, value: any): void;

interface InputOptions {
  required?: boolean;
  trimWhitespace?: boolean;
}

Input and Output Handling

Environment and State Management

Environment variable management, secret masking, and state preservation across action execution phases.

function exportVariable(name: string, val: any): void;
function setSecret(secret: string): void;
function addPath(inputPath: string): void;
function saveState(name: string, value: any): void;
function getState(name: string): string;

Environment and State Management

Logging and Annotations

Comprehensive logging system with multiple severity levels and GitHub Actions annotation support for creating contextual feedback.

function debug(message: string): void;
function info(message: string): void;
function warning(message: string | Error, properties?: AnnotationProperties): void;
function error(message: string | Error, properties?: AnnotationProperties): void;
function notice(message: string | Error, properties?: AnnotationProperties): void;
function setFailed(message: string | Error): void;
function setCommandEcho(enabled: boolean): void;

interface AnnotationProperties {
  title?: string;
  file?: string;
  startLine?: number;
  endLine?: number;
  startColumn?: number;
  endColumn?: number;
}

Logging and Annotations

Output Grouping

Organize log output in collapsible groups for better readability in workflow logs.

function startGroup(name: string): void;
function endGroup(): void;
function group<T>(name: string, fn: () => Promise<T>): Promise<T>;

Output Grouping

Job Summaries

Rich HTML content generation for creating detailed, formatted summaries that appear in GitHub Actions workflow runs.

interface Summary {
  write(options?: SummaryWriteOptions): Promise<Summary>;
  clear(): Promise<Summary>;
  addRaw(text: string, addEOL?: boolean): Summary;
  addCodeBlock(code: string, lang?: string): Summary;
  addList(items: string[], ordered?: boolean): Summary;
  addTable(rows: SummaryTableRow[]): Summary;
  addHeading(text: string, level?: number | string): Summary;
  addImage(src: string, alt: string, options?: SummaryImageOptions): Summary;
  // ... additional formatting methods
}

const summary: Summary;

Job Summaries

OIDC Token Generation

Secure JWT ID token generation for authenticating with third-party cloud providers and services.

function getIDToken(aud?: string): Promise<string>;

OIDC Token Generation

Path Utilities

Cross-platform path manipulation utilities for handling file paths across different operating systems.

function toPosixPath(pth: string): string;
function toWin32Path(pth: string): string;
function toPlatformPath(pth: string): string;

Path Utilities

Platform Detection

Runtime environment detection and system information gathering for platform-specific logic.

namespace platform {
  const platform: string;
  const arch: string;
  const isWindows: boolean;
  const isMacOS: boolean;
  const isLinux: boolean;
  function getDetails(): Promise<PlatformDetails>;
}

interface PlatformDetails {
  name: string;
  platform: string;
  arch: string;
  version: string;
  isWindows: boolean;
  isMacOS: boolean;
  isLinux: boolean;
}

Platform Detection

Types

enum ExitCode {
  Success = 0,
  Failure = 1
}

interface InputOptions {
  required?: boolean;
  trimWhitespace?: boolean;
}

interface AnnotationProperties {
  title?: string;
  file?: string;
  startLine?: number;
  endLine?: number;
  startColumn?: number;
  endColumn?: number;
}