Documentation
¶
Index ¶
- func GetRefType(ref string) string
- func IsReusableWorkflow(ref string) bool
- func IsSimpleRef(ref string) bool
- func ParseWorkflowYAML(filePath string, data []byte) (*yaml.Node, error)
- type Concurrency
- type Container
- type ContainerCredentials
- type Defaults
- type Environment
- type Job
- type RunDefaults
- type Step
- type Strategy
- type Workflow
- type WorkflowAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRefType ¶
GetRefType determines the type of a Git reference string.
- ref: The Git reference string to analyze
Returns: A string indicating the reference type: "sha", "short_sha", "version", "branch", or "unknown"
func IsReusableWorkflow ¶ added in v0.2.0
IsReusableWorkflow checks if an action reference is actually a reusable workflow
func IsSimpleRef ¶
IsSimpleRef checks if a reference string contains only letters and digits.
- ref: The reference string to check
Returns: true if the string contains only letters (a-z, A-Z) and digits (0-9), false otherwise
func ParseWorkflowYAML ¶
ParseWorkflowYAML parses YAML content from a workflow file into a structured Node tree. It preserves line numbers and structure for precise updates and handles empty files gracefully.
- filePath: The path to the workflow file being parsed (used for error messages). - data: The raw YAML content as a byte slice to be parsed.
Returns:
- A pointer to the root yaml.Node of the parsed YAML structure.
- nil and no error if the file is empty.
- nil and an error if parsing fails.
Types ¶
type Concurrency ¶
type Concurrency struct {
Group string `yaml:"group"` // Concurrency group name
CancelInProgress any `yaml:"cancel-in-progress,omitempty"` // Whether to cancel in-progress runs
}
Concurrency represents concurrency settings
type Container ¶
type Container struct {
Image string `yaml:"image"` // Container image to use
Credentials *ContainerCredentials `yaml:"credentials,omitempty"` // Registry credentials
Env map[string]any `yaml:"env,omitempty"` // Container environment variables
Ports []any `yaml:"ports,omitempty"` // Ports to expose
Volumes []string `yaml:"volumes,omitempty"` // Volumes to mount
Options string `yaml:"options,omitempty"` // Additional Docker options
}
Container represents a container configuration
type ContainerCredentials ¶
type ContainerCredentials struct {
Username string `yaml:"username"` // Registry username
Password string `yaml:"password"` // Registry password
}
ContainerCredentials represents credentials for a container
type Defaults ¶
type Defaults struct {
Run *RunDefaults `yaml:"run,omitempty"` // Default run settings
}
Defaults represents default settings for all jobs
type Environment ¶
type Environment struct {
Name string `yaml:"name"` // Environment name
URL string `yaml:"url,omitempty"` // Environment URL
}
Environment represents an environment configuration
type Job ¶
type Job struct {
Name string `yaml:"name,omitempty"` // Display name of the job
Needs any `yaml:"needs,omitempty"` // Dependencies on other jobs
Permissions any `yaml:"permissions,omitempty"` // Job-level permissions
RunsOn any `yaml:"runs-on,omitempty"` // Runner type(s) to use
Environment any `yaml:"environment,omitempty"` // Deployment environment
Outputs map[string]string `yaml:"outputs,omitempty"` // Job outputs for other jobs
Env map[string]any `yaml:"env,omitempty"` // Job-level environment variables
Defaults *Defaults `yaml:"defaults,omitempty"` // Job-specific default settings
If any `yaml:"if,omitempty"` // Conditional execution
Steps []Step `yaml:"steps,omitempty"` // Steps to execute in the job
TimeoutMinutes any `yaml:"timeout-minutes,omitempty"` // Job timeout
Strategy *Strategy `yaml:"strategy,omitempty"` // Build matrix strategy
ContinueOnError any `yaml:"continue-on-error,omitempty"` // Whether to continue on failure
Container any `yaml:"container,omitempty"` // Container to run the job in
Services map[string]Container `yaml:"services,omitempty"` // Service containers
Concurrency any `yaml:"concurrency,omitempty"` // Job-level concurrency
Uses string `yaml:"uses,omitempty"` // Reusable workflow reference
With map[string]any `yaml:"with,omitempty"` // Inputs for reusable workflow
Secrets any `yaml:"secrets,omitempty"` // Secrets for reusable workflow
}
Job represents a job within a workflow
type RunDefaults ¶
type RunDefaults struct {
Shell string `yaml:"shell,omitempty"` // Default shell to use
WorkingDirectory string `yaml:"working-directory,omitempty"` // Default working directory
}
RunDefaults represents default run settings
type Step ¶
type Step struct {
ID string `yaml:"id,omitempty"` // Step identifier
If any `yaml:"if,omitempty"` // Conditional execution
Name string `yaml:"name,omitempty"` // Display name of the step
Uses string `yaml:"uses,omitempty"` // Action reference
Run string `yaml:"run,omitempty"` // Command to run
WorkingDirectory string `yaml:"working-directory,omitempty"` // Step-specific working directory
Shell string `yaml:"shell,omitempty"` // Step-specific shell
With map[string]any `yaml:"with,omitempty"` // Inputs for the action
Env map[string]any `yaml:"env,omitempty"` // Step-level environment variables
ContinueOnError any `yaml:"continue-on-error,omitempty"` // Whether to continue on failure
TimeoutMinutes any `yaml:"timeout-minutes,omitempty"` // Step timeout
}
Step represents a step within a job
type Strategy ¶
type Strategy struct {
Matrix any `yaml:"matrix"` // Matrix configuration
FailFast any `yaml:"fail-fast,omitempty"` // Whether to cancel all jobs if any fail
MaxParallel any `yaml:"max-parallel,omitempty"` // Maximum parallel jobs
}
Strategy represents a build matrix strategy
type Workflow ¶
type Workflow struct {
Name string `yaml:"name,omitempty"` // Name of the workflow
RunName string `yaml:"run-name,omitempty"` // Dynamic name for workflow runs
On any `yaml:"on"` // Event triggers for the workflow
Permissions any `yaml:"permissions,omitempty"` // Workflow-level permissions
Env map[string]any `yaml:"env,omitempty"` // Workflow-level environment variables
Defaults *Defaults `yaml:"defaults,omitempty"` // Default settings for all jobs
Concurrency any `yaml:"concurrency,omitempty"` // Concurrency group settings
Jobs map[string]Job `yaml:"jobs"` // The jobs that make up the workflow
}
Workflow represents the GitHub Actions workflow file structure This matches the YAML structure of GitHub Actions workflow files.
type WorkflowAction ¶
type WorkflowAction struct {
Name string // Owner or organization name
Repo string // Repository name (potentially including subpath)
Ref string // Tag, branch, or SHA reference
Type string // Action type: "github", "docker", "local", or "unknown"
}
WorkflowAction represents an action reference (uses: xxx/yyy@version) This struct holds the parsed components of a GitHub Action reference.
func FindAllActions ¶
func FindAllActions(workflow *Workflow) []WorkflowAction
FindAllActions finds all action references in a workflow struct
- workflow: The parsed workflow structure to analyze
Returns: A slice of WorkflowAction objects representing all GitHub actions used in the workflow
func ParseActionReference ¶
func ParseActionReference(uses string) (WorkflowAction, error)
ParseActionReference parses a "uses:" line into owner, repo, and ref
- uses: The raw action reference string (e.g., "actions/checkout@v4")
Returns: A WorkflowAction struct with the parsed components and an error if parsing fails