Documentation
¶
Index ¶
- Constants
- func EvaluateCallerWith(jobID string, job *Job, gitCtx map[string]any, results map[string]*JobResult, ...) (map[string]any, error)
- func EvaluateConcurrency(rc *model.RawConcurrency, jobID string, job *Job, gitCtx map[string]any, ...) (string, bool, error)
- func EvaluateJobIfExpression(jobID string, job *Job, gitCtx map[string]any, results map[string]*JobResult, ...) (bool, error)
- func EvaluateWorkflowCallOutputs(spec *WorkflowCallSpec, gitCtx *model.GithubContext, vars map[string]string, ...) (map[string]string, error)
- func MatchCallerInputsAgainstSpec(spec *WorkflowCallSpec, evaluated map[string]any) (map[string]any, error)
- func NewInterpeter(jobID string, job *model.Job, matrix map[string]any, ...) exprparser.Interpreter
- func ParseCallerSecrets(node yaml.Node) (inherit bool, mapping map[string]string, err error)
- func ReadWorkflowRawConcurrency(content []byte) (*model.RawConcurrency, error)
- func ValidateCallerSecrets(spec *WorkflowCallSpec, mapping map[string]string) error
- type ContainerSpec
- type Defaults
- type Event
- type ExpressionEvaluator
- type InputSpec
- type InputType
- type Job
- type JobOutputs
- type JobResult
- type OutputSpec
- type ParseOption
- type RunDefaults
- type SecretSpec
- type SingleWorkflow
- type Step
- type Strategy
- type UsesKind
- type UsesRef
- type WorkflowCallSpec
- type WorkflowDispatchInput
Constants ¶
const SecretsInherit = "inherit"
SecretsInherit is the literal keyword used in a caller's `secrets: inherit` directive
Variables ¶
This section is empty.
Functions ¶
func EvaluateCallerWith ¶
func EvaluateCallerWith( jobID string, job *Job, gitCtx map[string]any, results map[string]*JobResult, vars map[string]string, inputs map[string]any, ) (map[string]any, error)
EvaluateCallerWith evaluates the caller-side expressions in `job.With` against the provided contexts
func EvaluateConcurrency ¶
func EvaluateJobIfExpression ¶
func EvaluateWorkflowCallOutputs ¶
func EvaluateWorkflowCallOutputs(spec *WorkflowCallSpec, gitCtx *model.GithubContext, vars map[string]string, inputs map[string]any, jobOutputs JobOutputs) (map[string]string, error)
EvaluateWorkflowCallOutputs evaluates a called workflow's "on.workflow_call.outputs.<name>.value" expressions against the provided contexts.
func MatchCallerInputsAgainstSpec ¶
func MatchCallerInputsAgainstSpec(spec *WorkflowCallSpec, evaluated map[string]any) (map[string]any, error)
MatchCallerInputsAgainstSpec checks the caller's already-evaluated `with:` values against the callee's declared `on.workflow_call.inputs` schema
func NewInterpeter ¶
func NewInterpeter( jobID string, job *model.Job, matrix map[string]any, gitCtx *model.GithubContext, results map[string]*JobResult, vars map[string]string, inputs map[string]any, ) exprparser.Interpreter
NewInterpeter returns an interpeter used in the server, need github, needs, strategy, matrix, inputs context only, see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
func ParseCallerSecrets ¶
ParseCallerSecrets decodes a caller's "secrets:" YAML node into one of two forms:
- inherit == true: the caller wrote `secrets: inherit`; mapping is nil
- inherit == false, mapping == {alias: source_name}: explicit mapping. Each value must be of the form `${{ secrets.NAME }}`.
Both alias and source name are upper-cased: secret names are case-insensitive (matching GitHub), and Gitea stores secrets upper-cased, so this keeps lookups and schema validation consistent.
func ReadWorkflowRawConcurrency ¶
func ReadWorkflowRawConcurrency(content []byte) (*model.RawConcurrency, error)
func ValidateCallerSecrets ¶
func ValidateCallerSecrets(spec *WorkflowCallSpec, mapping map[string]string) error
ValidateCallerSecrets checks a caller's parsed explicit-mapping `secrets:` against the called workflow's declared `on.workflow_call.secrets` schema.
Types ¶
type ContainerSpec ¶
type ContainerSpec struct {
Image string `yaml:"image,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Ports []string `yaml:"ports,omitempty"`
Volumes []string `yaml:"volumes,omitempty"`
Options string `yaml:"options,omitempty"`
Credentials map[string]string `yaml:"credentials,omitempty"`
Cmd []string `yaml:"cmd,omitempty"`
}
type Defaults ¶
type Defaults struct {
Run RunDefaults `yaml:"run,omitempty"`
}
type Event ¶
type Event struct {
Name string
// contains filtered or unexported fields
}
func (*Event) Inputs ¶
func (evt *Event) Inputs() []WorkflowDispatchInput
func (*Event) IsSchedule ¶
type ExpressionEvaluator ¶
type ExpressionEvaluator struct {
// contains filtered or unexported fields
}
ExpressionEvaluator is copied from runner.expressionEvaluator, to avoid unnecessary dependencies
func NewExpressionEvaluator ¶
func NewExpressionEvaluator(interpreter exprparser.Interpreter) *ExpressionEvaluator
func (ExpressionEvaluator) EvaluateYamlNode ¶
func (ee ExpressionEvaluator) EvaluateYamlNode(node *yaml.Node) error
func (ExpressionEvaluator) Interpolate ¶
func (ee ExpressionEvaluator) Interpolate(in string) string
type InputSpec ¶
type InputSpec struct {
Description string `yaml:"description"`
Required bool `yaml:"required"`
Default yaml.Node `yaml:"default"`
Type InputType `yaml:"type"`
}
InputSpec describes a single workflow_call input declaration.
type InputType ¶
type InputType string
InputType enumerates the allowed types for a workflow_call input.
type Job ¶
type Job struct {
Name string `yaml:"name,omitempty"`
RawNeeds yaml.Node `yaml:"needs,omitempty"`
RawRunsOn yaml.Node `yaml:"runs-on,omitempty"`
Env yaml.Node `yaml:"env,omitempty"`
If yaml.Node `yaml:"if,omitempty"`
Steps []*Step `yaml:"steps,omitempty"`
TimeoutMinutes string `yaml:"timeout-minutes,omitempty"`
RawContinueOnError yaml.Node `yaml:"continue-on-error,omitempty"`
Services map[string]*ContainerSpec `yaml:"services,omitempty"`
Strategy Strategy `yaml:"strategy,omitempty"`
RawContainer yaml.Node `yaml:"container,omitempty"`
Defaults Defaults `yaml:"defaults,omitempty"`
Outputs map[string]string `yaml:"outputs,omitempty"`
Uses string `yaml:"uses,omitempty"`
With map[string]any `yaml:"with,omitempty"`
RawSecrets yaml.Node `yaml:"secrets,omitempty"`
RawConcurrency *model.RawConcurrency `yaml:"concurrency,omitempty"`
RawPermissions yaml.Node `yaml:"permissions,omitempty"`
}
func (*Job) EraseNeeds ¶
func (*Job) GetContinueOnError ¶
GetContinueOnError decodes the continue-on-error field to a bool. The field may be a literal bool or an already-evaluated expression node.
type JobOutputs ¶
JobOutputs is the per-job-id outputs map used for evaluating workflow_call outputs.
type OutputSpec ¶
OutputSpec describes a single workflow_call output declaration.
type ParseOption ¶
type ParseOption func(c *parseContext)
func WithGitContext ¶
func WithGitContext(context *model.GithubContext) ParseOption
func WithInputs ¶
func WithInputs(inputs map[string]any) ParseOption
func WithVars ¶
func WithVars(vars map[string]string) ParseOption
type RunDefaults ¶
type SecretSpec ¶
SecretSpec describes a single workflow_call secret declaration.
type SingleWorkflow ¶
type SingleWorkflow struct {
Name string `yaml:"name,omitempty"`
RawOn yaml.Node `yaml:"on,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
RawJobs yaml.Node `yaml:"jobs,omitempty"`
Defaults Defaults `yaml:"defaults,omitempty"`
RawPermissions yaml.Node `yaml:"permissions,omitempty"`
RunName string `yaml:"run-name,omitempty"`
}
SingleWorkflow is a workflow with single job and single matrix
func Parse ¶
func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error)
func (*SingleWorkflow) Job ¶
func (w *SingleWorkflow) Job() (string, *Job)
func (*SingleWorkflow) Marshal ¶
func (w *SingleWorkflow) Marshal() ([]byte, error)
type Step ¶
type Step struct {
ID string `yaml:"id,omitempty"`
If yaml.Node `yaml:"if,omitempty"`
Name string `yaml:"name,omitempty"`
Uses string `yaml:"uses,omitempty"`
Run string `yaml:"run,omitempty"`
WorkingDirectory string `yaml:"working-directory,omitempty"`
Shell string `yaml:"shell,omitempty"`
Env yaml.Node `yaml:"env,omitempty"`
With map[string]string `yaml:"with,omitempty"`
ContinueOnError bool `yaml:"continue-on-error,omitempty"`
TimeoutMinutes string `yaml:"timeout-minutes,omitempty"`
}
type UsesKind ¶
type UsesKind int
UsesKind enumerates the supported forms of a reusable workflow "uses:" value.
const ( // UsesKindLocalSameRepo is "./<dir>/foo.yml" - a path inside the calling repository. // For example: "./.gitea/workflows/foo.yml" UsesKindLocalSameRepo UsesKind = iota + 1 // UsesKindLocalCrossRepo is "owner/repo/<dir>/foo.yml@ref" - a workflow in another repo on the same instance. // For example: "owner/repo/.gitea/workflows/foo.yml@ref" UsesKindLocalCrossRepo )
type UsesRef ¶
type UsesRef struct {
Kind UsesKind
Owner string // empty for UsesKindLocalSameRepo
Repo string // empty for UsesKindLocalSameRepo
Path string // workflow file path inside the source repo
Ref string // git ref; empty for UsesKindLocalSameRepo
}
UsesRef is the parsed form of a reusable workflow "uses:" value.
func ParseUses ¶
ParseUses parses the SYNTAX of a reusable workflow "uses:" value into a UsesRef. Two forms are supported:
- "./<dir>/foo.yml" (UsesKindLocalSameRepo, no @ref)
- "OWNER/REPO/<dir>/foo.yml@REF" (UsesKindLocalCrossRepo)
It deliberately does NOT validate that <dir> is an allowed workflow directory: the allowed directories are instance-configurable (WORKFLOW_DIRS / SCOPED_WORKFLOW_DIRS). The caller (services/actions.ResolveUses) enforces the directory allowlist. The returned Path is the cleaned, repo-relative file path.
type WorkflowCallSpec ¶
type WorkflowCallSpec struct {
Inputs map[string]InputSpec
Secrets map[string]SecretSpec
Outputs map[string]OutputSpec
}
WorkflowCallSpec is the parsed "on.workflow_call" schema of a called workflow.
func ParseWorkflowCallSpec ¶
func ParseWorkflowCallSpec(content []byte) (*WorkflowCallSpec, error)
ParseWorkflowCallSpec extracts on.workflow_call.{inputs,secrets,outputs} from a workflow YAML. Returns an error if the workflow does not declare on.workflow_call at all.