Documentation
¶
Index ¶
- 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, cron *actions_model.ActionSchedule) 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 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 GetAllRerunJobs(job *actions_model.ActionRunJob, allJobs []*actions_model.ActionRunJob) []*actions_model.ActionRunJob
- func GetFailedRerunJobs(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, ...) error
- func NewNotifier() notify_service.Notifier
- func NotifyWorkflowRunStatusUpdateWithReload(ctx context.Context, job *actions_model.ActionRunJob)
- 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, error)
- func PrepareToStartRunWithConcurrency(ctx context.Context, run *actions_model.ActionRun) (actions_model.Status, error)
- func RerunWorkflowRunJobs(ctx context.Context, repo *repo_model.Repository, run *actions_model.ActionRun, ...) 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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CancelAbandonedJobs ¶
CancelAbandonedJobs cancels jobs that have not been picked by any runner for a long time
func CancelPreviousJobs ¶ added in v1.23.6
func CancelPreviousJobs(ctx context.Context, repoID int64, ref, workflowID string, event webhook_module.HookEventType) error
func CleanRepoScheduleTasks ¶ added in v1.23.6
func CleanRepoScheduleTasks(ctx context.Context, repo *repo_model.Repository) error
func Cleanup ¶ added in v1.21.0
Cleanup removes expired actions logs, data, artifacts and used ephemeral runners
func CleanupArtifacts ¶ added in v1.21.0
CleanupArtifacts removes expired add need-deleted artifacts and set records expired status
func CleanupEphemeralRunners ¶ added in v1.24.0
CleanupEphemeralRunners removes used ephemeral runners which are no longer able to process jobs
func CleanupEphemeralRunnersByPickedTaskOfRepo ¶ added in v1.24.0
CleanupEphemeralRunnersByPickedTaskOfRepo removes all ephemeral runners that have active/finished tasks on the given repository
func CleanupExpiredLogs ¶ added in v1.25.0
CleanupExpiredLogs removes logs which are older than the configured retention time
func CreateAuthorizationToken ¶ added in v1.22.0
func CreateCommitStatusForRunJobs ¶ added in v1.26.0
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 ¶ added in v1.21.0
func CreateScheduleTask(ctx context.Context, cron *actions_model.ActionSchedule) error
CreateScheduleTask creates a scheduled task from a cron action schedule. It creates an action run based on the schedule, inserts it into the database, and creates commit statuses for each job.
func CreateVariable ¶ added in v1.22.0
func CreateVariable(ctx context.Context, ownerID, repoID int64, name, data, description string) (*actions_model.ActionVariable, error)
func DeleteRun ¶ added in v1.25.0
func DeleteRun(ctx context.Context, run *actions_model.ActionRun) error
DeleteRun deletes workflow run, including all logs and artifacts.
func DeleteVariableByID ¶ added in v1.22.0
func DeleteVariableByName ¶ added in v1.22.0
func DetectAndHandleSchedules ¶ added in v1.21.5
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 ¶ added in v1.24.0
func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, repo *repo_model.Repository, gitRepo *git.Repository, workflowID, ref string, processInputs func(model *model.WorkflowDispatch, inputs map[string]any) error) (runID int64, _ error)
func EmitJobsIfReadyByJobs ¶ added in v1.26.0
func EmitJobsIfReadyByJobs(jobs []*actions_model.ActionRunJob)
func EmitJobsIfReadyByRun ¶ added in v1.26.0
func EnableOrDisableWorkflow ¶ added in v1.24.0
func EnableOrDisableWorkflow(ctx *context.APIContext, workflowID string, isEnable bool) error
func EvaluateJobConcurrencyFillModel ¶ added in v1.26.0
func EvaluateJobConcurrencyFillModel(ctx context.Context, run *actions_model.ActionRun, 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 ¶ added in v1.26.0
func EvaluateRunConcurrencyFillModel(ctx context.Context, run *actions_model.ActionRun, 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's model fields with `concurrency.group` and `concurrency.cancel-in-progress`. 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 ¶ added in v1.26.0
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 ¶ added in v1.24.0
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
func GetAllRerunJobs ¶ added in v1.21.9
func GetAllRerunJobs(job *actions_model.ActionRunJob, allJobs []*actions_model.ActionRunJob) []*actions_model.ActionRunJob
GetAllRerunJobs returns the target job and all jobs that transitively depend on it. Downstream jobs are included regardless of their current status.
func GetFailedRerunJobs ¶ added in v1.26.0
func GetFailedRerunJobs(allJobs []*actions_model.ActionRunJob) []*actions_model.ActionRunJob
GetFailedRerunJobs returns all failed jobs and their downstream dependent jobs that need to be rerun
func GetRunsFromCommitStatuses ¶ added in v1.26.0
func GetRunsFromCommitStatuses(ctx context.Context, statuses []*git_model.CommitStatus) ([]*actions_model.ActionRun, error)
func GetVariable ¶ added in v1.22.0
func GetVariable(ctx context.Context, opts actions_model.FindVariablesOpts) (*actions_model.ActionVariable, error)
func InsertRun ¶ added in v1.26.0
func InsertRun(ctx context.Context, run *actions_model.ActionRun, jobs []*jobparser.SingleWorkflow, vars map[string]string, inputs map[string]any) error
InsertRun inserts a run The title will be cut off at 255 characters if it's longer than 255 characters.
func NewNotifier ¶
func NewNotifier() notify_service.Notifier
NewNotifier create a new actionsNotifier notifier
func NotifyWorkflowRunStatusUpdateWithReload ¶ added in v1.25.0
func NotifyWorkflowRunStatusUpdateWithReload(ctx context.Context, job *actions_model.ActionRunJob)
func ParseAuthorizationToken ¶ added in v1.22.0
func PickTask ¶ added in v1.23.4
func PickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv1.Task, bool, error)
func PrepareRunAndInsert ¶ added in v1.26.0
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 ¶ added in v1.26.0
func PrepareToStartJobWithConcurrency(ctx context.Context, job *actions_model.ActionRunJob) (actions_model.Status, 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) and any error encountered during the process.
func PrepareToStartRunWithConcurrency ¶ added in v1.26.0
func PrepareToStartRunWithConcurrency(ctx context.Context, run *actions_model.ActionRun) (actions_model.Status, error)
PrepareToStartRunWithConcurrency prepares a run to start by its evaluated concurrency group and cancelling previous jobs if necessary. It returns the new status of the run (either StatusBlocked or StatusWaiting) and any error encountered during the process.
func RerunWorkflowRunJobs ¶ added in v1.26.0
func RerunWorkflowRunJobs(ctx context.Context, repo *repo_model.Repository, run *actions_model.ActionRun, jobsToRerun []*actions_model.ActionRunJob) error
RerunWorkflowRunJobs reruns the given jobs of a workflow run. jobsToRerun must include all jobs to be rerun (the target job and its transitively dependent jobs). A job is blocked (waiting for dependencies) if the run itself is blocked or if any of its needs are also being rerun.
func StartScheduleTasks ¶ added in v1.21.0
StartScheduleTasks start the task
func StopEndlessTasks ¶
StopEndlessTasks stops the tasks which have running status and continuous updates, but don't end for a long time
func StopZombieTasks ¶
StopZombieTasks stops the task which have running status, but haven't been updated for a long time
func TokenToTaskID ¶ added in v1.22.4
TokenToTaskID returns the TaskID associated with the provided JWT token
func UpdateVariableNameData ¶ added in v1.23.4
func UpdateVariableNameData(ctx context.Context, variable *actions_model.ActionVariable) (bool, error)
Types ¶
type API ¶ added in v1.22.0
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 ¶ added in v1.25.0
func GenerateGiteaContext ¶ added in v1.24.0
func GenerateGiteaContext(run *actions_model.ActionRun, job *actions_model.ActionRunJob) GiteaContext
GenerateGiteaContext generate the gitea context without token and gitea_runtime_token job can be nil when generating a context for parsing workflow-level expressions
func (*GiteaContext) ToGitHubContext ¶ added in v1.25.0
func (g *GiteaContext) ToGitHubContext() *model.GithubContext