Documentation
¶
Index ¶
- Constants
- func ApproveRuns(ctx context.Context, repo *repo_model.Repository, doer *user_model.User, ...) error
- func CancelAbandonedJobs(ctx context.Context) error
- func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID string, ...) error
- func CleanRepoScheduleTasks(ctx context.Context, repo *repo_model.Repository) error
- func Cleanup(ctx context.Context) error
- func CleanupArtifacts(taskCtx context.Context) error
- func CleanupEphemeralRunners(ctx context.Context) error
- func CleanupEphemeralRunnersByPickedTaskOfRepo(ctx context.Context, repoID int64) error
- func CleanupExpiredLogs(ctx context.Context) error
- func CreateAuthorizationToken(taskID, runID, jobID int64) (string, error)
- func CreateCommitStatusForRunJobs(ctx context.Context, run *actions_model.ActionRun, ...)
- func CreateScheduleTask(ctx context.Context, spec *actions_model.ActionScheduleSpec) error
- func CreateVariable(ctx context.Context, ownerID, repoID int64, name, data, description string) (*actions_model.ActionVariable, error)
- func DeleteRun(ctx context.Context, run *actions_model.ActionRun) error
- func DeleteVariableByID(ctx context.Context, variableID int64) error
- func DeleteVariableByName(ctx context.Context, ownerID, repoID int64, name string) error
- func DetectAndHandleSchedules(ctx context.Context, repo *repo_model.Repository) error
- func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, repo *repo_model.Repository, ...) (runID int64, _ error)
- func DownloadArtifactV4(ctx *context.Base, art *actions_model.ActionArtifact) error
- func DownloadArtifactV4ReadStorage(ctx *context.Base, art *actions_model.ActionArtifact) error
- func DownloadArtifactV4ServeDirect(ctx *context.Base, art *actions_model.ActionArtifact) bool
- func EmitJobsIfReadyByJobs(jobs []*actions_model.ActionRunJob)
- func EmitJobsIfReadyByRun(runID int64) error
- func EnableOrDisableWorkflow(ctx *context.APIContext, workflowID string, isEnable bool) error
- func EvaluateJobConcurrencyFillModel(ctx context.Context, run *actions_model.ActionRun, ...) error
- func EvaluateRunConcurrencyFillModel(ctx context.Context, run *actions_model.ActionRun, ...) error
- func ExtractJobPermissionsFromWorkflow(flow *jobparser.SingleWorkflow, job *jobparser.Job) *repo_model.ActionsTokenPermissions
- func FindTaskNeeds(ctx context.Context, job *actions_model.ActionRunJob) (map[string]*TaskNeed, error)
- func GetArtifactV4ServeDirectURL(art *actions_model.ActionArtifact, method string) (string, error)
- func GetFailedJobsForRerun(allJobs []*actions_model.ActionRunJob) []*actions_model.ActionRunJob
- func GetRunsFromCommitStatuses(ctx context.Context, statuses []*git_model.CommitStatus) ([]*actions_model.ActionRun, error)
- func GetVariable(ctx context.Context, opts actions_model.FindVariablesOpts) (*actions_model.ActionVariable, error)
- func Init(ctx context.Context) error
- func InsertRun(ctx context.Context, run *actions_model.ActionRun, content []byte, ...) error
- func IsArtifactV4(art *actions_model.ActionArtifact) bool
- func LoadParsedScopedWorkflows(ctx context.Context, sourceRepo *repo_model.Repository) (sha string, parsed []*actions_module.ParsedScopedWorkflow, err error)
- func NewNotifier() notify_service.Notifier
- func NotifyWorkflowJobStatusUpdateWithTask(ctx context.Context, job *actions_model.ActionRunJob, ...)
- func NotifyWorkflowJobsAndRunsStatusUpdate(ctx context.Context, jobs []*actions_model.ActionRunJob)
- func NotifyWorkflowJobsStatusUpdate(ctx context.Context, jobs ...*actions_model.ActionRunJob)
- func NotifyWorkflowRunStatusUpdate(ctx context.Context, run *actions_model.ActionRun)
- func NotifyWorkflowRunStatusUpdateWithReload(ctx context.Context, repoID, runID int64)
- func ParseAuthorizationToken(req *http.Request) (int64, error)
- func PickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv1.Task, bool, error)
- func PrepareRunAndInsert(ctx context.Context, content []byte, run *actions_model.ActionRun, ...) error
- func PrepareToStartJobWithConcurrency(ctx context.Context, job *actions_model.ActionRunJob) (actions_model.Status, []*actions_model.ActionRunJob, error)
- func PrepareToStartRunWithConcurrency(ctx context.Context, attempt *actions_model.ActionRunAttempt) (actions_model.Status, []*actions_model.ActionRunJob, error)
- func RerunWorkflowRunJobs(ctx context.Context, repo *repo_model.Repository, run *actions_model.ActionRun, ...) (*actions_model.ActionRunAttempt, error)
- func ResolveUses(ctx context.Context, uses string) (*jobparser.UsesRef, error)
- func ScopedWorkflowContent(ctx context.Context, sourceRepo *repo_model.Repository, entryName string) ([]byte, error)
- func StartScheduleTasks(ctx context.Context) error
- func StopEndlessTasks(ctx context.Context) error
- func StopZombieTasks(ctx context.Context) error
- func TokenToTaskID(token string) (int64, error)
- func UpdateVariableNameData(ctx context.Context, variable *actions_model.ActionVariable) (bool, error)
- type API
- type GiteaContext
- type TaskNeed
Constants ¶
const MaxReusableCallLevels = 9
MaxReusableCallLevels caps how deep a reusable workflow can nest: a top-level caller may have at most MaxReusableCallLevels nested callers below it.
Variables ¶
This section is empty.
Functions ¶
func ApproveRuns ¶
func ApproveRuns(ctx context.Context, repo *repo_model.Repository, doer *user_model.User, runIDs []int64) error
func CancelAbandonedJobs ¶
CancelAbandonedJobs cancels jobs that have not been picked by any runner for a long time
func CancelPreviousJobs ¶
func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID string, event webhook_module.HookEventType) error
func CleanRepoScheduleTasks ¶
func CleanRepoScheduleTasks(ctx context.Context, repo *repo_model.Repository) error
func CleanupArtifacts ¶
CleanupArtifacts removes expired add need-deleted artifacts and set records expired status
func CleanupEphemeralRunners ¶
CleanupEphemeralRunners removes used ephemeral runners which are no longer able to process jobs
func CleanupEphemeralRunnersByPickedTaskOfRepo ¶
CleanupEphemeralRunnersByPickedTaskOfRepo removes all ephemeral runners that have active/finished tasks on the given repository
func CleanupExpiredLogs ¶
CleanupExpiredLogs removes logs which are older than the configured retention time
func CreateCommitStatusForRunJobs ¶
func CreateCommitStatusForRunJobs(ctx context.Context, run *actions_model.ActionRun, jobs ...*actions_model.ActionRunJob)
CreateCommitStatusForRunJobs creates a commit status for the given job if it has a supported event and related commit. It won't return an error failed, but will log it, because it's not critical.
func CreateScheduleTask ¶
func CreateScheduleTask(ctx context.Context, spec *actions_model.ActionScheduleSpec) error
CreateScheduleTask creates a scheduled task from a cron action schedule spec. It creates an action run based on the schedule, inserts it into the database, and creates commit statuses for each job.
func CreateVariable ¶
func CreateVariable(ctx context.Context, ownerID, repoID int64, name, data, description string) (*actions_model.ActionVariable, error)
func DeleteRun ¶
func DeleteRun(ctx context.Context, run *actions_model.ActionRun) error
DeleteRun deletes workflow run, including all logs and artifacts.
func DeleteVariableByName ¶
func DetectAndHandleSchedules ¶
func DetectAndHandleSchedules(ctx context.Context, repo *repo_model.Repository) error
DetectAndHandleSchedules detects the schedule workflows on the default branch and create schedule tasks
func DispatchActionWorkflow ¶
func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, repo *repo_model.Repository, gitRepo *git.Repository, workflowID, ref string, scopedWorkflowSourceRepoID int64, processInputs func(model *model.WorkflowDispatch, inputs map[string]any) error) (runID int64, _ error)
DispatchActionWorkflow manually triggers a workflow_dispatch run. scopedWorkflowSourceRepoID selects the workflow source: 0 means a repo-level workflow in this repo; a non-zero value is the source repo of a scoped workflow.
func DownloadArtifactV4 ¶
func DownloadArtifactV4(ctx *context.Base, art *actions_model.ActionArtifact) error
func DownloadArtifactV4ReadStorage ¶
func DownloadArtifactV4ReadStorage(ctx *context.Base, art *actions_model.ActionArtifact) error
func DownloadArtifactV4ServeDirect ¶
func DownloadArtifactV4ServeDirect(ctx *context.Base, art *actions_model.ActionArtifact) bool
func EmitJobsIfReadyByJobs ¶
func EmitJobsIfReadyByJobs(jobs []*actions_model.ActionRunJob)
func EmitJobsIfReadyByRun ¶
func EnableOrDisableWorkflow ¶
func EnableOrDisableWorkflow(ctx *context.APIContext, workflowID string, isEnable bool) error
func EvaluateJobConcurrencyFillModel ¶
func EvaluateJobConcurrencyFillModel(ctx context.Context, run *actions_model.ActionRun, attempt *actions_model.ActionRunAttempt, actionRunJob *actions_model.ActionRunJob, vars map[string]string, inputs map[string]any) error
EvaluateJobConcurrencyFillModel evaluates the expressions in a job-level concurrency, and fills the job's model fields with `concurrency.group` and `concurrency.cancel-in-progress`. Job-level concurrency may depend on other job's outputs (via `needs`): `concurrency.group: my-group-${{ needs.job1.outputs.out1 }}` If the needed jobs haven't been executed yet, this evaluation will also fail. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idconcurrency
func EvaluateRunConcurrencyFillModel ¶
func EvaluateRunConcurrencyFillModel(ctx context.Context, run *actions_model.ActionRun, attempt *actions_model.ActionRunAttempt, wfRawConcurrency *act_model.RawConcurrency, vars map[string]string, inputs map[string]any) error
EvaluateRunConcurrencyFillModel evaluates the expressions in a run-level (workflow) concurrency, and fills the run attempt model with the evaluated `concurrency.group` and `concurrency.cancel-in-progress` values. Workflow-level concurrency doesn't depend on the job outputs, so it can always be evaluated if there is no syntax error. See https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#concurrency
func ExtractJobPermissionsFromWorkflow ¶
func ExtractJobPermissionsFromWorkflow(flow *jobparser.SingleWorkflow, job *jobparser.Job) *repo_model.ActionsTokenPermissions
ExtractJobPermissionsFromWorkflow extracts permissions from an already parsed workflow/job. It returns nil if neither workflow nor job explicitly specifies permissions.
func FindTaskNeeds ¶
func FindTaskNeeds(ctx context.Context, job *actions_model.ActionRunJob) (map[string]*TaskNeed, error)
FindTaskNeeds finds the `needs` for the task by the task's job. Lookup is scoped to the same ParentJobID.
func GetArtifactV4ServeDirectURL ¶
func GetArtifactV4ServeDirectURL(art *actions_model.ActionArtifact, method string) (string, error)
func GetFailedJobsForRerun ¶
func GetFailedJobsForRerun(allJobs []*actions_model.ActionRunJob) []*actions_model.ActionRunJob
GetFailedJobsForRerun returns the failed or cancelled jobs in a run.
func GetRunsFromCommitStatuses ¶
func GetRunsFromCommitStatuses(ctx context.Context, statuses []*git_model.CommitStatus) ([]*actions_model.ActionRun, error)
func GetVariable ¶
func GetVariable(ctx context.Context, opts actions_model.FindVariablesOpts) (*actions_model.ActionVariable, error)
func InsertRun ¶
func InsertRun(ctx context.Context, run *actions_model.ActionRun, content []byte, vars map[string]string, inputs map[string]any, wfRawConcurrency *act_model.RawConcurrency) error
InsertRun inserts a run The title will be cut off at 255 characters if it's longer than 255 characters.
func IsArtifactV4 ¶
func IsArtifactV4(art *actions_model.ActionArtifact) bool
IsArtifactV4 detects whether the artifact is likely from v4. V4 backend stores the files as a single combined zip file per artifact, and ensures ContentEncoding contains a slash (otherwise this uses application/zip instead of the custom mime type), which is not the case for the old backend.
func LoadParsedScopedWorkflows ¶
func LoadParsedScopedWorkflows(ctx context.Context, sourceRepo *repo_model.Repository) (sha string, parsed []*actions_module.ParsedScopedWorkflow, err error)
LoadParsedScopedWorkflows returns the source repo's parsed scoped workflows at its current default-branch HEAD.
func NewNotifier ¶
func NewNotifier() notify_service.Notifier
NewNotifier create a new actionsNotifier notifier
func NotifyWorkflowJobStatusUpdateWithTask ¶
func NotifyWorkflowJobStatusUpdateWithTask(ctx context.Context, job *actions_model.ActionRunJob, task *actions_model.ActionTask)
NotifyWorkflowJobStatusUpdateWithTask notifies a single job status update when a concrete task is available. Use it for runner/task lifecycle callbacks so the notification includes the originating task context.
func NotifyWorkflowJobsAndRunsStatusUpdate ¶
func NotifyWorkflowJobsAndRunsStatusUpdate(ctx context.Context, jobs []*actions_model.ActionRunJob)
NotifyWorkflowJobsAndRunsStatusUpdate notifies status changes for a batch of jobs and the runs they affect. Use it when a workflow operation updates multiple jobs and runs.
func NotifyWorkflowJobsStatusUpdate ¶
func NotifyWorkflowJobsStatusUpdate(ctx context.Context, jobs ...*actions_model.ActionRunJob)
NotifyWorkflowJobsStatusUpdate notifies status updates for jobs without task. Use it for batch or single-job notifications after state changes.
func NotifyWorkflowRunStatusUpdate ¶
func NotifyWorkflowRunStatusUpdate(ctx context.Context, run *actions_model.ActionRun)
NotifyWorkflowRunStatusUpdate notifies a run status update using the latest attempt trigger user when available. Use it for run-level notifications when the caller already has the run model loaded.
func NotifyWorkflowRunStatusUpdateWithReload ¶
NotifyWorkflowRunStatusUpdateWithReload reloads the run before notifying its status update. Use it when only repo/run IDs are available or when the in-memory run may be stale after job updates.
func PickTask ¶
func PickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv1.Task, bool, error)
func PrepareRunAndInsert ¶
func PrepareRunAndInsert(ctx context.Context, content []byte, run *actions_model.ActionRun, inputsWithDefaults map[string]any) error
PrepareRunAndInsert prepares a run and inserts it into the database It parses the workflow content, evaluates concurrency if needed, and inserts the run and its jobs into the database. The title will be cut off at 255 characters if it's longer than 255 characters.
func PrepareToStartJobWithConcurrency ¶
func PrepareToStartJobWithConcurrency(ctx context.Context, job *actions_model.ActionRunJob) (actions_model.Status, []*actions_model.ActionRunJob, error)
PrepareToStartJobWithConcurrency prepares a job to start by its evaluated concurrency group and cancelling previous jobs if necessary. It returns the new status of the job (either StatusBlocked or StatusWaiting), any cancelled jobs, and any error encountered during the process.
func PrepareToStartRunWithConcurrency ¶
func PrepareToStartRunWithConcurrency(ctx context.Context, attempt *actions_model.ActionRunAttempt) (actions_model.Status, []*actions_model.ActionRunJob, error)
PrepareToStartRunWithConcurrency prepares a run attempt to start by its evaluated concurrency group and cancelling previous jobs if necessary. It returns the new status of the run attempt (either StatusBlocked or StatusWaiting), any cancelled jobs, and any error encountered during the process.
func RerunWorkflowRunJobs ¶
func RerunWorkflowRunJobs(ctx context.Context, repo *repo_model.Repository, run *actions_model.ActionRun, triggerUser *user_model.User, jobsToRerun []*actions_model.ActionRunJob) (*actions_model.ActionRunAttempt, error)
RerunWorkflowRunJobs reruns the given jobs of a workflow run. An empty jobsToRerun means rerunning the whole run. Otherwise jobsToRerun contains only the user-requested target jobs; downstream dependent jobs are expanded internally while building the rerun plan.
The three stages below (legacy backfill, plan build, plan exec) deliberately run in separate DB transactions rather than one big outer transaction:
- execRerunPlan performs slow work (loading variables, YAML unmarshal, concurrency expression evaluation) before opening its own transaction, so the tx stays focused on inserts/updates. (Exception: reusable workflow caller expansion runs inside the tx, see expandReusableWorkflowCaller's doc.)
- The legacy backfill is idempotent-friendly: if it succeeds but a later stage fails, a subsequent rerun will observe run.LatestAttemptID != 0 and skip the backfill, continuing naturally. No data corruption or stuck state results from partial progress.
Fast validations that can catch failures early (workflow disabled, run not done, etc.) are therefore pushed into validateRerun so we rarely enter createOriginalAttemptForLegacyRun only to fail afterwards.
func ResolveUses ¶
ResolveUses normalizes and parses a reusable workflow `uses:` value. It first rewrites an absolute URL pointing to this instance into the cross-repo form (rejecting external URLs), then validates the syntax via jobparser.ParseUses.
func ScopedWorkflowContent ¶
func ScopedWorkflowContent(ctx context.Context, sourceRepo *repo_model.Repository, entryName string) ([]byte, error)
ScopedWorkflowContent returns one scoped workflow's raw content (by entry name) at the source repo's current default-branch HEAD, or nil if no such workflow exists there.
func StartScheduleTasks ¶
StartScheduleTasks start the task
func StopEndlessTasks ¶
StopEndlessTasks stops tasks in running/cancelling status with continuous updates that don't end for a long time
func StopZombieTasks ¶
StopZombieTasks stops tasks in running/cancelling status that haven't been updated for a long time
func TokenToTaskID ¶
TokenToTaskID returns the TaskID associated with the provided JWT token
func UpdateVariableNameData ¶
func UpdateVariableNameData(ctx context.Context, variable *actions_model.ActionVariable) (bool, error)
Types ¶
type API ¶
type API interface {
// ListActionsSecrets list secrets
ListActionsSecrets(*context.APIContext)
// CreateOrUpdateSecret create or update a secret
CreateOrUpdateSecret(*context.APIContext)
// DeleteSecret delete a secret
DeleteSecret(*context.APIContext)
// ListVariables list variables
ListVariables(*context.APIContext)
// GetVariable get a variable
GetVariable(*context.APIContext)
// DeleteVariable delete a variable
DeleteVariable(*context.APIContext)
// CreateVariable create a variable
CreateVariable(*context.APIContext)
// UpdateVariable update a variable
UpdateVariable(*context.APIContext)
// CreateRegistrationToken get registration token
CreateRegistrationToken(*context.APIContext)
// ListRunners list runners
ListRunners(*context.APIContext)
// GetRunner get a runner
GetRunner(*context.APIContext)
// DeleteRunner delete runner
DeleteRunner(*context.APIContext)
// UpdateRunner update runner
UpdateRunner(*context.APIContext)
// ListWorkflowJobs list jobs
ListWorkflowJobs(*context.APIContext)
// ListWorkflowRuns list runs
ListWorkflowRuns(*context.APIContext)
}
API for actions of a repository or organization
type GiteaContext ¶
func GenerateGiteaContext ¶
func GenerateGiteaContext(ctx context.Context, run *actions_model.ActionRun, attempt *actions_model.ActionRunAttempt, job *actions_model.ActionRunJob) GiteaContext
GenerateGiteaContext generate the gitea context without token and gitea_runtime_token. attempt and job can be nil when generating a context for parsing workflow-level expressions.
The run_attempt value is resolved with the following precedence:
- attempt.Attempt - the explicit attempt argument, or run.GetLatestAttempt() as a fallback
- job.Attempt - only used when neither an explicit nor latest attempt is available
- "1" - when none of the above apply (first-run parse time, before the first attempt exists)
func (*GiteaContext) ToGitHubContext ¶
func (g *GiteaContext) ToGitHubContext() *model.GithubContext