actions

package
v0.0.0-...-70db0ab Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvVarCI              = "CI"
	EnvVarWorkflow        = "GITHUB_WORKFLOW"
	EnvVarRunID           = "GITHUB_RUN_ID"
	EnvVarRunNumber       = "GITHUB_RUN_NUMBER"
	EnvVarRunAttempt      = "GITHUB_RUN_ATTEMPT"
	EnvVarJob             = "GITHUB_JOB"
	EnvVarAction          = "GITHUB_ACTION"
	EnvVarActionPath      = "GITHUB_ACTION_PATH"
	EnvVarActions         = "GITHUB_ACTIONS"
	EnvVarActor           = "GITHUB_ACTOR"
	EnvVarRepository      = "GITHUB_REPOSITORY"
	EnvVarEventName       = "GITHUB_EVENT_NAME"
	EnvVarEventPath       = "GITHUB_EVENT_PATH"
	EnvVarWorkspace       = "GITHUB_WORKSPACE"
	EnvVarSha             = "GITHUB_SHA"
	EnvVarRef             = "GITHUB_REF"
	EnvVarRefName         = "GITHUB_REF_NAME"
	EnvVarRefProtected    = "GITHUB_REF_PROTECTED"
	EnvVarRefType         = "GITHUB_REF_TYPE"
	EnvVarHeadRef         = "GITHUB_HEAD_REF"
	EnvVarBaseRef         = "GITHUB_BASE_REF"
	EnvVarServerURL       = "GITHUB_SERVER_URL"
	EnvVarAPIURL          = "GITHUB_API_URL"
	EnvVarGraphQLURL      = "GITHUB_GRAPHQL_URL"
	EnvVarRunnerName      = "RUNNER_NAME"
	EnvVarRunnerOS        = "RUNNER_OS"
	EnvVarRunnerArch      = "RUNNER_ARCH"
	EnvVarRunnerTemp      = "RUNNER_TEMP"
	EnvVarRunnerToolCache = "RUNNER_TOOL_CACHE"

	EnvVarEnv  = "GITHUB_ENV"
	EnvVarPath = "GITHUB_PATH"

	EnvVarToken = "GITHUB_TOKEN" //nolint:gosec

	EnvVarRepositoryOwner  = "GITHUB_REPOSITORY_OWNER"
	EnvVarRetentionDays    = "GITHUB_RETENTION_DAYS"
	EnvVarStepSummary      = "GITHUB_STEP_SUMMARY"
	EnvVarActionRepository = "GITHUB_ACTION_REPOSITORY"
)
View Source
const (
	RunsUsingDockerImagePrefix = "docker://"
	RunsUsingDocker            = "docker"
	RunsUsingNode12            = "node12"
	RunsUsingNode16            = "node16"
	RunsUsingComposite         = "composite"
)
View Source
const (
	CommandDebug        = "debug"
	CommandGroup        = "group"
	CommandEndGroup     = "endgroup"
	CommandSaveState    = "save-state"
	CommandSetOutput    = "set-output"
	CommandNotice       = "notice"
	CommandWarning      = "warning"
	CommandError        = "error"
	CommandAddMask      = "add-mask"
	CommandEcho         = "echo"
	CommandStopCommands = "stop-commands"
)

Variables

View Source
var ErrNotAWorkflowCommand = errors.New("not a workflow command")
View Source
var ErrNotAnAction = errors.New("action.yaml/action.yml not found")

Functions

func ErrIsNotAWorkflowCommand

func ErrIsNotAWorkflowCommand(err error) bool

func Expand

func Expand(s string, mapping ExpandFunc) string

func ExpandBytes

func ExpandBytes(b []byte, mapping ExpandFunc) (p []byte)

func NewWorkflowCommandWriter

func NewWorkflowCommandWriter(callback func(*WorkflowCommand) []byte, w io.Writer) io.Writer

func WithInsecure

func WithInsecure(co *cloneOpts) error

Types

type Arch

type Arch string
const (
	ArchX86   Arch = "X86"
	ArchX64   Arch = "X64"
	ArchARM   Arch = "ARM"
	ArchARM64 Arch = "ARM64"
)

func (Arch) String

func (a Arch) String() string

type CloneOpt

type CloneOpt func(*cloneOpts) error

func WithGitHubURL

func WithGitHubURL(u string) CloneOpt

func WithPath

func WithPath(p string) CloneOpt

type CtxOpt

type CtxOpt func(*GlobalContext) error

func WithEnv

func WithEnv(env map[string]string) CtxOpt

func WithInputs

func WithInputs(inputs map[string]string) CtxOpt

func WithJobName

func WithJobName(job string) CtxOpt

func WithSecrets

func WithSecrets(secrets map[string]string) CtxOpt

func WithToken

func WithToken(token string) CtxOpt

func WithWorkflowName

func WithWorkflowName(workflow string) CtxOpt

type ExpandFunc

type ExpandFunc func(string) string

type Expander

type Expander struct {
	ExpandFunc ExpandFunc
}

func NewExpander

func NewExpander(f ExpandFunc) *Expander

func (*Expander) Expand

func (e *Expander) Expand(s string) string

func (*Expander) ExpandBytes

func (e *Expander) ExpandBytes(b []byte) []byte

type GitHubContext

type GitHubContext struct {
	Action          string
	ActionPath      string
	Actor           string
	BaseRef         string
	Event           string
	EventName       string
	EventPath       string
	HeadRef         string
	Job             string
	Ref             string
	RefName         string
	RefProtected    bool
	RefType         RefType
	Repository      string
	RepositoryOwner string
	RunID           string
	RunNumber       int
	RunAttempt      int
	ServerURL       *url.URL
	Sha             string
	Token           string
	Workflow        string
	Workspace       string
}

GitHubContext represents the GitHub Context https://docs.github.com/en/actions/learn-github-actions/Context#github-context

func (*GitHubContext) GetString

func (c *GitHubContext) GetString(key string) string

type GlobalContext

type GlobalContext struct {
	GitHubContext  *GitHubContext
	EnvContext     map[string]string
	JobContext     *JobContext
	StepsContext   map[string]*StepsContext
	RunnerContext  *RunnerContext
	InputsContext  map[string]string
	SecretsContext map[string]string
	NeedsContext   map[string]*NeedsContext
}

func EmptyContext

func EmptyContext(opts ...CtxOpt) *GlobalContext

func NewContext

func NewContext(opts ...CtxOpt) (*GlobalContext, error)

func NewContextFromPath

func NewContextFromPath(ctx context.Context, path string, opts ...CtxOpt) (*GlobalContext, error)

func (*GlobalContext) AddEnv

func (c *GlobalContext) AddEnv(env map[string]string)

func (*GlobalContext) EnvArr

func (c *GlobalContext) EnvArr() []string

func (*GlobalContext) EnvMap

func (c *GlobalContext) EnvMap() map[string]string

func (*GlobalContext) GetString

func (c *GlobalContext) GetString(key string) string

type Job

type Job struct {
	Name        string      `json:"name,omitempty" yaml:"name,omitempty"`
	Permissions interface{} `json:"permissions,omitempty" yaml:"permissions,omitempty"`
	Needs       interface{} `json:"needs,omitempty" yaml:"needs,omitempty"`
	If          interface{} `json:"if,omitempty" yaml:"if,omitempty"`
	RunsOn      string      `json:"runs-on,omitempty" yaml:"runs-on,omitempty"`
	Environment *struct {
		Name string   `json:"name,omitempty" yaml:"name,omitempty"`
		URL  *url.URL `json:"url,omitempty" yaml:"url,omitempty"`
	} `json:"environment,omitempty" yaml:"environment,omitempty"`
	Concurrency interface{}       `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`
	Outputs     map[string]string `json:"outputs,omitempty" yaml:"outputs,omitempty"`
	Env         map[string]string `json:"env,omitempty" yaml:"env,omitempty"`
	Container   interface{}       `json:"container,omitempty" yaml:"container,omitempty"`
	Steps       []*Step           `json:"steps,omitempty" yaml:"steps,omitempty"`
}

type JobContext

type JobContext struct {
	Container *struct {
		ID      string
		Network string
	}
	Services map[string]struct {
		ID      string
		Network string
		// not sure if this is the correct representation
		Ports map[string]string
	}
	Status string
}

func (*JobContext) GetString

func (c *JobContext) GetString(key string) string

type Metadata

type Metadata struct {
	Name        string `json:"name,omitempty" yaml:"name,omitempty"`
	Author      string `json:"author,omitempty" yaml:"author,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	Inputs      map[string]*struct {
		Description        string      `json:"input,omitempty" yaml:"input,omitempty"`
		Required           bool        `json:"required,omitempty" yaml:"required,omitempty"`
		Default            interface{} `json:"default,omitempty" yaml:"default,omitempty"`
		DeprecationMessage string      `json:"deprecationMessage,omitempty" yaml:"deprecationMessage,omitempty"`
	} `json:"inputs,omitempty" yaml:"inputs,omitempty"`
	Outputs map[string]*struct {
		Description string `json:"output,omitempty" yaml:"output,omitempty"`
	} `json:"outputs,omitempty" yaml:"outputs,omitempty"`
	Runs *struct {
		Plugin         string            `json:"plugin,omitempty" yaml:"plugin,omitempty"`
		Using          string            `json:"using,omitempty" yaml:"using,omitempty"`
		Pre            string            `json:"pre,omitempty" yaml:"pre,omitempty"`
		Main           string            `json:"main,omitempty" yaml:"main,omitempty"`
		Post           string            `json:"post,omitempty" yaml:"post,omitempty"`
		Image          string            `json:"image,omitempty" yaml:"image,omitempty"`
		PreEntrypoint  string            `json:"pre-entrypoint,omitempty" yaml:"pre-entrypoint,omitempty"`
		Entrypoint     string            `json:"entrypoint,omitempty" yaml:"entrypoint,omitempty"`
		PostEntrypoint string            `json:"post-entrypoint,omitempty" yaml:"post-entrypoint,omitempty"`
		Args           []string          `json:"args,omitempty" yaml:"args,omitempty"`
		Env            map[string]string `json:"env,omitempty" yaml:"env,omitempty"`
		Steps          []*Step           `json:"steps,omitempty" yaml:"steps,omitempty"`
	} `json:"runs,omitempty" yaml:"runs,omitempty"`
}

func Clone

func Clone(u *uses.Uses, opts ...CloneOpt) (*Metadata, error)

func CloneContext

func CloneContext(ctx context.Context, u *uses.Uses, opts ...CloneOpt) (*Metadata, error)

func NewMetadataFromReader

func NewMetadataFromReader(r io.Reader) (*Metadata, error)

func (*Metadata) IsComposite

func (m *Metadata) IsComposite() bool

func (*Metadata) WithFromInputs

func (m *Metadata) WithFromInputs() map[string]string

type NeedsContext

type NeedsContext struct {
	Outputs map[string]string
}

func (*NeedsContext) GetString

func (c *NeedsContext) GetString(key string) string

type OS

type OS string
const (
	OSLinux   OS = "Linux"
	OSWindows OS = "Windows"
	OSDarwin  OS = "macOS"
)

func (OS) String

func (o OS) String() string

type RefType

type RefType string
const (
	RefTypeTag    RefType = "tag"
	RefTypeBranch RefType = "branch"
)

func (RefType) String

func (r RefType) String() string

type RunnerContext

type RunnerContext struct {
	Name      string
	OS        OS
	Arch      Arch
	Temp      string
	ToolCache string
}

func (*RunnerContext) GetString

func (c *RunnerContext) GetString(key string) string

type Step

type Step struct {
	Shell            string            `json:"shell,omitempty" yaml:"shell,omitempty"`
	If               string            `json:"if,omitempty" yaml:"if,omitempty"`
	Name             string            `json:"name,omitempty" yaml:"name,omitempty"`
	ID               string            `json:"id,omitempty" yaml:"id,omitempty"`
	Env              map[string]string `json:"env,omitempty" yaml:"env,omitempty"`
	WorkingDirectory string            `json:"working-directory,omitempty" yaml:"working-directory,omitempty"`
	Uses             string            `json:"uses,omitempty" yaml:"uses,omitempty"`
	With             map[string]string `json:"with,omitempty" yaml:"with,omitempty"`
	Run              string            `json:"run,omitempty" yaml:"run,omitempty"`
}

type StepsContext

type StepsContext struct {
	Outputs    map[string]string
	Conclusion string
	Outcome    string
}

func (*StepsContext) GetString

func (c *StepsContext) GetString(key string) string

type Workflow

type Workflow struct {
	Name string          `json:"name,omitempty" yaml:"name,omitempty"`
	Jobs map[string]*Job `json:"jobs,omitempty" yaml:"jobs,omitempty"`
}

type WorkflowCommand

type WorkflowCommand struct {
	Command    string
	Parameters map[string]string
	Value      string
}

func ParseStringWorkflowCommand

func ParseStringWorkflowCommand(s string) (*WorkflowCommand, error)

func ParseWorkflowCommand

func ParseWorkflowCommand(b []byte) (*WorkflowCommand, error)

func (*WorkflowCommand) GetName

func (c *WorkflowCommand) GetName() string

func (*WorkflowCommand) GoString

func (c *WorkflowCommand) GoString() string

func (*WorkflowCommand) String

func (c *WorkflowCommand) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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