core

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPublicKey = errors.New("invalid public key: must be 32 bytes")

ErrInvalidPublicKey is returned when the provided public key is not 32 bytes long.

Functions

func AddMatcher

func AddMatcher(w io.Writer, p string) error

AddMatcher sends an add matcher command to the workflow writer. The problem matcher is defined by the path to the problem matcher file.

func AddPath

func AddPath(p string) error

AddPath writes a path entry to be persisted for the current GitHub Actions workflow run.

func CreateTempDir

func CreateTempDir() (string, error)

CreateTempDir creates a temporary directory and returns its path.

func Debug

func Debug(w io.Writer, message string) error

Debug sends a debug message to the workflow log writer.

func EncryptSecret

func EncryptSecret(publicKey []byte, value string) (string, error)

EncryptSecret encrypts a secret value using the recipient's public key with a NaCl sealed box. This is compatible with GitHub's secret encryption which uses libsodium sealed boxes.

func EndGroup

func EndGroup(w io.Writer) error

EndGroup ends the current group of messages in the workflow log writer.

func Error

func Error(w io.Writer, message string, properties AnnotationProperties) error

Error sends an error message to the workflow log writer.

func ExportVariable

func ExportVariable(key, value string) error

ExportVariable writes an environment variable to be persisted for the GitHub Actions workflow. It also sets the variable in the current process environment.

func GetBooleanInput

func GetBooleanInput(name string, opts InputOptions) (bool, error)

GetBooleanInput gets the input value of the boolean type in the YAML 1.2 "core schema" specification. Supported boolean input list: true | True | TRUE | false | False | FALSE.

func GetInput

func GetInput(name string, opts InputOptions) (string, error)

GetInput gets the value of an input. Unless TrimWhitespace is set to false in InputOptions, the value is also trimmed. Returns an empty string if the value is not defined.

func GetMultilineInput

func GetMultilineInput(name string, opts InputOptions) ([]string, error)

GetMultilineInput gets the values of a multiline input. Each value is also trimmed unless TrimWhitespace is set to false.

func GetState

func GetState(name string) string

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

func GetTempDir

func GetTempDir() (string, error)

GetTempDir returns the path to the temporary directory. It checks the environment variables in the following order: 1. RUNNER_TEMP (for GitHub Actions runner) 2. TEMPDIR (for Linux) 3. TMP (for Windows) If none of these environment variables are set or point to a valid directory, an error is returned.

func Info

func Info(w io.Writer, message string) error

Info writes a message directly to the workflow log writer. Unlike other log functions, info does not use a workflow command.

func IsDebug

func IsDebug() bool

IsDebug returns true if the current GitHub Actions step is in debug mode.

func IssueCommand

func IssueCommand(w io.Writer, c *Command) error

IssueCommand issues a GitHub Actions command by writing it to the provided writer.

func IssueFileCommand

func IssueFileCommand(p, key, value string) error

IssueFileCommand writes a key-value pair to a GitHub Actions environment file. It always uses heredoc format with a unique delimiter to prevent injection.

func Notice

func Notice(w io.Writer, message string, properties AnnotationProperties) error

Notice sends an notice message to the workflow log writer.

func RemoveMatcher

func RemoveMatcher(w io.Writer, owner string) error

RemoveMatcher sends a remove matcher command to the workflow writer. The owner is defined in the problem matcher file that was added.

func SaveState

func SaveState(key, value string) error

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

func SetFailed

func SetFailed(w io.Writer, message string) error

SetFailed sets the action status to failed by logging an error message. The caller is responsible for exiting the process with an appropriate exit code.

func SetOutput

func SetOutput(key, value string) error

SetOutput writes an output to be persisted for the current GitHub Actions workflow step.

func SetSecret

func SetSecret(w io.Writer, value string) error

SetSecret sends an mask command to the workflow writer.

func StartGroup

func StartGroup(w io.Writer, name string) error

StartGroup starts a new group of messages in the workflow log writer.

func Warning

func Warning(w io.Writer, message string, properties AnnotationProperties) error

Warning sends an warning message to the workflow log writer.

func WriteSummary

func WriteSummary(value string) error

WriteSummary writes a summary to be persisted for the current GitHub Actions workflow step.

Types

type AnnotationProperties

type AnnotationProperties struct {
	Title     string
	File      string
	Column    int
	EndColumn int
	Line      int
	EndLine   int
}

AnnotationProperties represents the properties for a GitHub Actions annotation command.

func (*AnnotationProperties) GetCommandProperties

func (a *AnnotationProperties) GetCommandProperties() CommandProperties

GetCommandProperties returns the annotation properties as CommandProperties suitable for use with a GitHub Actions annotation command.

type Command

type Command struct {
	Type       CommandType
	Properties CommandProperties
	Message    string
}

Command represents a GitHub Actions workflow command with a type, properties, and message.

func NewCommand

func NewCommand(t CommandType, p CommandProperties, m string) (*Command, error)

NewCommand creates a new GitHub Actions command. It returns an error if the command type is empty.

func (*Command) String

func (c *Command) String() string

String prints the Command as a string.

type CommandProperties

type CommandProperties []CommandProperty

CommandProperties represents a slice of properties for a GitHub Actions command.

type CommandProperty

type CommandProperty struct {
	Key   string
	Value any
}

CommandProperty represents a key-value pair for a GitHub Actions command property.

type CommandType

type CommandType string

CommandType represents a GitHub Actions command type.

const (
	StartGroupCmd    CommandType = "group"
	EndGroupCmd      CommandType = "endgroup"
	DebugCmd         CommandType = "debug"
	ErrorCmd         CommandType = "error"
	WarningCmd       CommandType = "warning"
	NoticeCmd        CommandType = "notice"
	MaskCmd          CommandType = "add-mask"
	AddMatcherCmd    CommandType = "add-matcher"
	RemoveMatcherCmd CommandType = "remove-matcher"
)

type InputOptions

type InputOptions struct {
	// Required indicates if the input is required.
	// If required and not present, GetInput will return an error.
	Required bool
	// TrimWhitespace indicates if the input should be trimmed.
	// If nil, the input is trimmed by default.
	TrimWhitespace *bool
}

InputOptions are options for the GetInput, GetMultilineInput and GetBooleanInput functions.

Jump to

Keyboard shortcuts

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