actions

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GithubEventPullRequest              = "pull_request"
	GithubEventPullRequestTarget        = "pull_request_target"
	GithubEventPullRequestReviewComment = "pull_request_review_comment"
	GithubEventPullRequestReview        = "pull_request_review"
	GithubEventRegistryPackage          = "registry_package"
	GithubEventCreate                   = "create"
	GithubEventDelete                   = "delete"
	GithubEventFork                     = "fork"
	GithubEventPush                     = "push"
	GithubEventIssues                   = "issues"
	GithubEventIssueComment             = "issue_comment"
	GithubEventRelease                  = "release"
	GithubEventPullRequestComment       = "pull_request_comment"
	GithubEventGollum                   = "gollum"
	GithubEventSchedule                 = "schedule"
)
View Source
const (
	MaxLineSize = 64 * 1024
	DBFSPrefix  = "actions_log/"
)

Variables

This section is empty.

Functions

func BuildSignature

func BuildSignature(tag tagType, vals ...string) []byte

BuildSignature builds a hmac signature for the input values. "tag" is an internal pre-defined static string to distinguish the signatures for different purpose.

func FormatLog

func FormatLog(timestamp time.Time, content string) string

func FullSteps

FullSteps returns steps with "Set up job" and "Complete job"

func GetContentFromEntry

func GetContentFromEntry(entry *git.TreeEntry) ([]byte, error)

func GetEventsFromContent

func GetEventsFromContent(content []byte) ([]*jobparser.Event, error)

func IsDefaultBranchWorkflow

func IsDefaultBranchWorkflow(triggedEvent webhook_module.HookEventType) bool

IsDefaultBranchWorkflow returns true if the event only triggers workflows on the default branch

func IsWorkflow

func IsWorkflow(path string) bool

func IsWorkflowOrScopedWorkflow

func IsWorkflowOrScopedWorkflow(path string) bool

IsWorkflowOrScopedWorkflow reports whether path is a workflow file under WORKFLOW_DIRS or SCOPED_WORKFLOW_DIRS.

func ListScopedWorkflows

func ListScopedWorkflows(commit *git.Commit) (string, git.Entries, error)

ListScopedWorkflows lists scoped workflow files (under SCOPED_WORKFLOW_DIRS) at the given commit.

func ListWorkflows

func ListWorkflows(commit *git.Commit) (string, git.Entries, error)

func OpenLogs

func OpenLogs(ctx context.Context, inStorage bool, filename string) (io.ReadSeekCloser, error)

func ParseLog

func ParseLog(in string) (time.Time, string, error)

func ReadLogs

func ReadLogs(ctx context.Context, inStorage bool, filename string, offset, limit int64) ([]*runnerv1.LogRow, error)

func RemoveLogs

func RemoveLogs(ctx context.Context, inStorage bool, filename string) error

func ScopedWorkflowStatusContextName

func ScopedWorkflowStatusContextName(prefix, displayName, jobName, event string) string

ScopedWorkflowStatusContextName prefixes a scoped run's status-check context with its source repo, set off by a colon: "<prefix>: <display> / <job> (<event>)".

func ShouldEventCreateCommitStatus

func ShouldEventCreateCommitStatus(event string) bool

ShouldEventCreateCommitStatus reports whether a run triggered by the given workflow `on:` event posts a commit status, so its context can serve as a required status check. TODO: this allowlist duplicates the truth in services/actions.getCommitStatusEventNameAndCommitID, which decides the actual event string and whether a status is posted. The two are kept in sync by hand and can drift; unify them into a single source so adding a status-producing event in one place automatically updates the other.

func TransferLogs

func TransferLogs(ctx context.Context, filename string) (func(), error)

TransferLogs transfers logs from DBFS to object storage. It happens when the file is complete and no more logs will be appended. It respects the file format in the filename like ".zst", and compresses the content if needed. The task log file must be marked as "log_in_storage=true" after the transfer.

func ValidateWorkflowContent

func ValidateWorkflowContent(content []byte) error

ValidateWorkflowContent catches structural errors (e.g. blank lines in run: | blocks) that model.ReadWorkflow alone does not detect.

func WorkflowDisplayName

func WorkflowDisplayName(file string, content []byte) string

WorkflowDisplayName returns a workflow's display name: its `name:` if non-blank, otherwise the base file name. This is the value used as the workflow segment of its commit-status context.

func WorkflowStatusContextName

func WorkflowStatusContextName(displayName, jobName, event string) string

WorkflowStatusContextName builds a workflow job's commit-status context name: "<display> / <job> (<event>)".

func WriteLogs

func WriteLogs(ctx context.Context, filename string, offset int64, rows []*runnerv1.LogRow) ([]int, error)

WriteLogs appends logs to DBFS file for temporary storage. It doesn't respect the file format in the filename like ".zst", since it's difficult to reopen a closed compressed file and append new content. Why doesn't it store logs in object storage directly? Because it's not efficient to append content to object storage.

Types

type CommitActionsStatusMap

type CommitActionsStatusMap map[int64]actions_model.Status

CommitActionsStatusMap maps CommitStatus.ID to the live ActionRunJob status for Gitea Actions rows.

func GetCommitActionsStatusMap

func GetCommitActionsStatusMap(ctx context.Context, statuses []*git_model.CommitStatus) CommitActionsStatusMap

GetCommitActionsStatusMap resolves the live ActionRunJob.Status for every CommitStatus row backed by Gitea Actions. Rows from other sources (external CIs, API) are left untouched and rendered from their stored State.

func (CommitActionsStatusMap) IconStatus

IconStatus returns the action status name to route the icon through repo/icons/action_status, or "" when the row isn't from Gitea Actions.

type DetectedWorkflow

type DetectedWorkflow struct {
	EntryName    string
	TriggerEvent *jobparser.Event
	Content      []byte
}

func DetectScheduledWorkflows

func DetectScheduledWorkflows(gitRepo *git.Repository, commit *git.Commit) ([]*DetectedWorkflow, error)

func DetectWorkflows

func DetectWorkflows(
	gitRepo *git.Repository,
	commit *git.Commit,
	triggedEvent webhook_module.HookEventType,
	payload api.Payloader,
	detectSchedule bool,
) (workflows, schedules, filtered []*DetectedWorkflow, err error)

func MatchScopedWorkflows

func MatchScopedWorkflows(
	parsed []*ParsedScopedWorkflow,
	consumerGitRepo *git.Repository,
	consumerCommit *git.Commit,
	triggedEvent webhook_module.HookEventType,
	payload api.Payloader,
) (matched, filtered []*DetectedWorkflow)

MatchScopedWorkflows evaluates already-parsed scoped workflows against one consuming event. It returns the workflows whose `on:` matches, and those that matched the event but were excluded by a branch/paths filter (filtered).

type ParsedScopedWorkflow

type ParsedScopedWorkflow struct {
	EntryName   string
	DisplayName string             // the workflow `name:` or base file name
	Content     []byte             // raw content of the workflow file
	Events      []*jobparser.Event // decoded `on:` events
}

ParsedScopedWorkflow is one scoped workflow's source-side parse result

func ParseScopedWorkflows

func ParseScopedWorkflows(sourceCommit *git.Commit) ([]*ParsedScopedWorkflow, error)

ParseScopedWorkflows lists and parses the scoped workflow files at sourceCommit (under SCOPED_WORKFLOW_DIRS).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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