core

package
v0.0.0-...-6b6fe65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 11 Imported by: 12

Documentation

Index

Constants

View Source
const (

	// StatusFailed is returned by Status() in case this action has been marked as failed
	StatusFailed = 1
	// StatusSuccess is returned by Status() in case this action has not been marked as failed. By default an action is claimed as successful
	StatusSuccess = 0

	GitHubOutputFilePathEnvName    = "GITHUB_OUTPUT"
	GitHubStateFilePathEnvName     = "GITHUB_STATE"
	GitHubExportEnvFilePathEnvName = "GITHUB_ENV"
	GitHubPathFilePathEnvName      = "GITHUB_PATH"
	GitHubSummaryPathEnvName       = "GITHUB_STEP_SUMMARY"

	ActionsGoJsonInputEnvName = "ACTION_GO_INPUTS"
)
View Source
const (
	// ActionsIDTokenRequestTokenEnvName is the env var containing the OIDC request token.
	ActionsIDTokenRequestTokenEnvName = "ACTIONS_ID_TOKEN_REQUEST_TOKEN"
	// ActionsIDTokenRequestURLEnvName is the env var containing the OIDC request URL.
	ActionsIDTokenRequestURLEnvName = "ACTIONS_ID_TOKEN_REQUEST_URL"
)
View Source
const EOF = "\n"

Variables

View Source
var Arch = jsArch()

Arch is the current CPU architecture (e.g. "x64", "arm64"). Mirrors os.arch() from Node.js — uses JavaScript naming conventions.

View Source
var IsLinux = runtime.GOOS == "linux"

IsLinux reports whether the current platform is Linux.

View Source
var IsMacOS = runtime.GOOS == "darwin"

IsMacOS reports whether the current platform is macOS.

View Source
var IsWindows = runtime.GOOS == "windows"

IsWindows reports whether the current platform is Windows.

View Source
var JobSummary = &Summary{}

JobSummary is the package-level summary instance, equivalent to core.summary in the JS toolkit.

View Source
var Platform = runtime.GOOS

Platform is the current operating system platform (e.g. "linux", "darwin", "windows"). Mirrors os.platform() from Node.js.

Functions

func AddPath

func AddPath(path string)

AddPath prepends inputPath to the PATH (for this action and future actions)

func AddStepSummary

func AddStepSummary(summary string)

AddStepSummary adds some custom Markdown for each job so that it will be displayed on the summary page of a workflow run. You can use job summaries to display and group unique content, such as test result summaries, so that someone viewing the result of a workflow run doesn't need to go into the logs to see important information related to the run, such as failures. see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary

func Debug

func Debug(message string)

Debug writes debug message to user log

func Debugf

func Debugf(format string, args ...interface{})

Debugf writes debug message to user log

func DeleteStepSummary

func DeleteStepSummary()

DeleteStepSummary completely remove a summary for the current step see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#removing-job-summaries

func EndGroup

func EndGroup()

EndGroup end an output group and folds it

func Error

func Error(message string, properties ...AnnotationProperties)

Error adds an error issue with optional annotation properties.

func Errorf

func Errorf(format string, args ...interface{})

Errorf adds a formatted error issue

func ExportVariable

func ExportVariable(name, value string)

ExportVariable sets the environment varaible name (for this action and future actions)

func GetBoolInput

func GetBoolInput(name string) bool

GetBoolInput gets the value of an input and returns whether it is a truthy value per the YAML 1.2 "core schema" specification: true | True | TRUE | false | False | FALSE. Returns false if the input is not set. Returns an error if the value is set but is not a valid boolean per the YAML spec.

func GetIDToken

func GetIDToken(audience string) (string, error)

GetIDToken gets the JSON Web Token (JWT) for the current workflow run. audience is an optional audience for the token; pass empty string for the default. The token is automatically masked from logs.

func GetInput

func GetInput(name string) (string, bool)

GetInput gets the value of an input. The value is also trimmed.

func GetInputOrDefault

func GetInputOrDefault(name, dflt string) string

GetInputOrDefault gets the value of an input. If value is not found, a default value is used

func GetMultilineInput

func GetMultilineInput(name string) []string

GetMultilineInput gets the values of a multiline input. Each value is trimmed. Returns an empty slice if the input is not set.

func GetState

func GetState(name string) string

GetState gets the value of an state set by this action's main execution.

func Group

func Group(name string, f func()) func()

Group wrap an asynchronous function call in a group, all logs of the function will be collapsed after completion

func Info

func Info(message string)

Info writes the message on the console

func Infof

func Infof(format string, args ...interface{})

Infof writes debug message to user log

func IsDebug

func IsDebug() bool

IsDebug returns whether the github actions is currently under debug

func Issue

func Issue(kind string, message ...string)

Issue displays a plain typed message following github actions interface

func IssueCommand

func IssueCommand(kind string, properties map[string]string, message string)

IssueCommand displays a typed message with properties following github actions interface. see https://github.com/actions/toolkit/blob/e69833ed16500afaa7d137a9cf6da76fb8fb54da/packages/core/src/command.ts#L19

func Notice

func Notice(message string, properties ...AnnotationProperties)

Notice adds a notice issue with optional annotation properties.

func Noticef

func Noticef(format string, args ...interface{})

Noticef adds a formatted notice issue

func ReplaceStepSummary

func ReplaceStepSummary(summary string)

ReplaceStepSummary clear all content for the current step see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#overwriting-job-summaries

func SaveState

func SaveState(name, value string)

SaveState saves state for current action, the state can only be retrieved by this action's post job execution.

func SetCommandEcho

func SetCommandEcho(enabled bool)

SetCommandEcho enables or disables the echoing of commands into stdout for the rest of the step. Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.

func SetFailed

func SetFailed(message string)

SetFailed sets the action status to failed and sets an error message

func SetFailedf

func SetFailedf(format string, args ...interface{})

SetFailedf sets the action status to failed and sets an error message

func SetOutput

func SetOutput(name, value string)

SetOutput sets the value of an output for future actions

func SetSecret

func SetSecret(secret string)

SetSecret registers a secret which will get masked from logs

func SetStdout

func SetStdout(w io.Writer)

func StartCommands

func StartCommands(endToken string)

StartCommands enables commands stopped until the endToken

func StartGroup

func StartGroup(name string)

StartGroup begin an output group. Output until the next `GroupEnd` will be foldable in this group

func StopCommands

func StopCommands(endToken string)

StopCommands Stops processing any workflow commands. Commands will be resumed when calling StartCommands(endToken) This special command allows you to log anything without accidentally running a workflow command. For example, you could stop logging to output an entire script that has comments.

func ToPlatformPath

func ToPlatformPath(pth string) string

ToPlatformPath converts the given path to the platform-specific form using the OS path separator.

func ToPosixPath

func ToPosixPath(pth string) string

ToPosixPath converts the given path to POSIX form. On Windows, backslashes are replaced with forward slashes.

func ToWin32Path

func ToWin32Path(pth string) string

ToWin32Path converts the given path to Windows form. Forward slashes are replaced with backslashes.

func Warning

func Warning(message string, properties ...AnnotationProperties)

Warning adds a warning issue with optional annotation properties.

func Warningf

func Warningf(format string, args ...interface{})

Warningf adds a formatted warning issue

func WithoutCommands

func WithoutCommands(endToken string, f func())

WithoutCommands executes the functions ensuring it does not execute any github actions commands. This special command allows you to log anything without accidentally running a workflow command. For example, you could stop logging to output an entire script that has comments.

Types

type AnnotationProperties

type AnnotationProperties struct {
	// A title for the annotation.
	Title string
	// The path of the file for which the annotation should be created.
	File string
	// The start line for the annotation.
	StartLine int
	// The end line for the annotation. Defaults to StartLine when StartLine is provided.
	EndLine int
	// The start column for the annotation. Cannot be sent when StartLine and EndLine are different values.
	StartColumn int
	// The end column for the annotation. Cannot be sent when StartLine and EndLine are different values.
	EndColumn int
}

AnnotationProperties optional properties that can be sent with annotation commands (notice, error, and warning). See https://docs.github.com/en/rest/reference/checks#create-a-check-run for more information about annotations.

type File

type File interface {
	io.Reader
	io.Writer
	io.Closer
}

type PlatformDetails

type PlatformDetails struct {
	// Name is the OS display name (e.g. "Ubuntu 22.04.1 LTS", "macOS 13.0").
	Name string
	// Platform is the OS platform identifier (e.g. "linux", "darwin", "windows").
	Platform string
	// Arch is the CPU architecture using JavaScript naming (e.g. "x64", "arm64").
	Arch string
	// Version is the OS version string.
	Version string
	// IsWindows reports whether the platform is Windows.
	IsWindows bool
	// IsMacOS reports whether the platform is macOS.
	IsMacOS bool
	// IsLinux reports whether the platform is Linux.
	IsLinux bool
}

PlatformDetails contains detailed information about the current operating system.

func GetDetails

func GetDetails() (PlatformDetails, error)

GetDetails returns detailed platform information including OS name and version. It executes OS-specific commands to retrieve this information.

type Summary

type Summary struct {
	// contains filtered or unexported fields
}

Summary is a builder for GitHub Actions job summaries. Use the package-level JobSummary variable rather than constructing directly.

func (*Summary) AddBreak

func (s *Summary) AddBreak() *Summary

AddBreak adds an HTML line break (<br>).

func (*Summary) AddCodeBlock

func (s *Summary) AddCodeBlock(code string, lang ...string) *Summary

AddCodeBlock adds an HTML code block to the buffer. lang is an optional language for syntax highlighting.

func (*Summary) AddDetails

func (s *Summary) AddDetails(label, content string) *Summary

AddDetails adds a collapsible HTML details element.

func (*Summary) AddEOL

func (s *Summary) AddEOL() *Summary

AddEOL appends an OS-specific end-of-line marker to the buffer.

func (*Summary) AddHeading

func (s *Summary) AddHeading(text string, level ...int) *Summary

AddHeading adds an HTML heading element (h1–h6). Level defaults to 1.

func (*Summary) AddImage

func (s *Summary) AddImage(src, alt string, options ...SummaryImageOptions) *Summary

AddImage adds an HTML image tag.

func (s *Summary) AddLink(text, href string) *Summary

AddLink adds an HTML anchor tag.

func (*Summary) AddList

func (s *Summary) AddList(items []string, ordered ...bool) *Summary

AddList adds an HTML list to the buffer. ordered controls whether an <ol> or <ul> is rendered (default: unordered).

func (*Summary) AddQuote

func (s *Summary) AddQuote(text string, cite ...string) *Summary

AddQuote adds an HTML blockquote. cite is an optional citation URL.

func (*Summary) AddRaw

func (s *Summary) AddRaw(text string, addEOL ...bool) *Summary

AddRaw adds raw text to the buffer.

func (*Summary) AddSeparator

func (s *Summary) AddSeparator() *Summary

AddSeparator adds an HTML thematic break (<hr>).

func (*Summary) AddTable

func (s *Summary) AddTable(rows [][]SummaryTableCell) *Summary

AddTable adds an HTML table to the buffer. Each row is a slice of SummaryTableCell or string values.

func (*Summary) Clear

func (s *Summary) Clear() error

Clear empties the buffer and wipes the summary file.

func (*Summary) EmptyBuffer

func (s *Summary) EmptyBuffer() *Summary

EmptyBuffer resets the buffer without writing to the file.

func (*Summary) IsEmptyBuffer

func (s *Summary) IsEmptyBuffer() bool

IsEmptyBuffer reports whether the buffer is empty.

func (*Summary) Stringify

func (s *Summary) Stringify() string

Stringify returns the current buffer content as a string.

func (*Summary) Write

func (s *Summary) Write(options ...SummaryWriteOptions) error

Write flushes the buffer to the summary file and clears the buffer. Appends by default; set options.Overwrite to replace existing content.

type SummaryImageOptions

type SummaryImageOptions struct {
	// Width in pixels (integer, no unit).
	Width string
	// Height in pixels (integer, no unit).
	Height string
}

SummaryImageOptions optional attributes for summary images.

type SummaryTableCell

type SummaryTableCell struct {
	// Data is the cell content.
	Data string
	// Header renders cell as header (<th>) when true.
	Header bool
	// Colspan is the number of columns the cell extends (optional, default "1").
	Colspan string
	// Rowspan is the number of rows the cell extends (optional, default "1").
	Rowspan string
}

SummaryTableCell represents a cell in a summary table.

type SummaryWriteOptions

type SummaryWriteOptions struct {
	// Overwrite replaces all existing content when true (default: false, appends).
	Overwrite bool
}

SummaryWriteOptions controls write behavior.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL