Documentation
¶
Overview ¶
Package actionpins provides action pin resolution for GitHub Actions, mapping repository references to their pinned commit SHAs. It is intentionally free of dependencies on pkg/workflow so it can be imported by any package without introducing import cycles.
Index ¶
- func ExtractRepo(uses string) string
- func ExtractVersion(uses string) string
- func FormatCacheKey(repo, version string) string
- func FormatReference(repo, sha, version string) string
- func GetActionPinWithData(actionRepo, version string, ctx *PinContext) (string, error)
- func GetCachedActionPin(repo string, ctx *PinContext) string
- type ActionPin
- type ActionPinsData
- type ActionYAMLInput
- type PinContext
- type SHAResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractRepo ¶
ExtractRepo extracts the action repository from a uses string. Examples: "actions/checkout@v5" -> "actions/checkout"
func ExtractVersion ¶
ExtractVersion extracts the version from a uses string. Examples: "actions/checkout@v5" -> "v5", "actions/checkout" -> ""
func FormatCacheKey ¶
FormatCacheKey generates a cache key for action resolution. Example: "actions/checkout@v4"
func FormatReference ¶
FormatReference formats an action reference with repo, SHA, and version comment. Example: "actions/checkout@abc123 # v4.1.0"
func GetActionPinWithData ¶
func GetActionPinWithData(actionRepo, version string, ctx *PinContext) (string, error)
GetActionPinWithData returns the pinned action reference for a given action@version. It consults ctx.Resolver first, then falls back to embedded pins. If ctx is nil, only embedded pins are consulted.
func GetCachedActionPin ¶
func GetCachedActionPin(repo string, ctx *PinContext) string
GetCachedActionPin returns the pinned action reference for a given repository, preferring the user's cache (via ctx.Resolver) over the embedded action_pins.json. If ctx is nil, only embedded pins are consulted.
Types ¶
type ActionPin ¶
type ActionPin struct {
Repo string `json:"repo"`
Version string `json:"version"`
SHA string `json:"sha"`
Inputs map[string]*ActionYAMLInput `json:"inputs,omitempty"`
}
ActionPin represents a pinned GitHub Action with its commit SHA.
func GetActionPinByRepo ¶
GetActionPinByRepo returns the latest ActionPin for a given repository, if any.
func GetActionPins ¶
func GetActionPins() []ActionPin
GetActionPins returns all loaded action pins sorted by version descending.
func GetActionPinsByRepo ¶
GetActionPinsByRepo returns the sorted (version-descending) list of action pins for the given repository. Returns nil if the repo has no pins.
type ActionPinsData ¶
ActionPinsData represents the structure of the embedded JSON file.
type ActionYAMLInput ¶
type ActionYAMLInput struct {
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Required bool `yaml:"required,omitempty" json:"required,omitempty"`
Default string `yaml:"default,omitempty" json:"default,omitempty"`
}
ActionYAMLInput holds an input definition parsed from a GitHub Action's action.yml.
type PinContext ¶
type PinContext struct {
// Resolver resolves SHAs dynamically via GitHub CLI. May be nil.
Resolver SHAResolver
// StrictMode controls how resolution failures are handled.
StrictMode bool
// Warnings is a shared map for deduplicating warning messages.
// Keys are cache keys in the form "repo@version".
Warnings map[string]bool
}
PinContext provides the runtime context needed for action pin resolution. Callers construct one from their own state (e.g. WorkflowData fields). The Warnings map is mutated in place to deduplicate warning output.
type SHAResolver ¶
SHAResolver resolves a GitHub Action's commit SHA for a given version tag.