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 ResolveActionPin(actionRepo, version string, ctx *PinContext) (string, error)
- func ResolveLatestActionPin(repo string, ctx *PinContext) string
- type ActionPin
- type ActionPinsData
- type ActionYAMLInput
- type PinContext
- type ResolutionErrorType
- type ResolutionFailure
- 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 ResolveActionPin ¶ added in v0.68.5
func ResolveActionPin(actionRepo, version string, ctx *PinContext) (string, error)
ResolveActionPin 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 ResolveLatestActionPin ¶ added in v0.69.0
func ResolveLatestActionPin(repo string, ctx *PinContext) string
ResolveLatestActionPin 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 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
// EnforcePinned requires unresolved refs to fail unless AllowActionRefs is true.
EnforcePinned bool
// AllowActionRefs lowers unresolved pinning failures to warnings.
// When false, unresolved action refs return an error.
AllowActionRefs bool
// Warnings is a shared map for deduplicating warning messages.
// Keys are cache keys in the form "repo@version".
Warnings map[string]bool
// RecordResolutionFailure receives unresolved pinning failures for auditing.
RecordResolutionFailure func(f ResolutionFailure)
}
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 ResolutionErrorType ¶ added in v0.69.1
type ResolutionErrorType string
ResolutionErrorType classifies unresolved action-ref pinning outcomes for auditing.
const ( // ResolutionErrorTypeDynamicResolutionFailed indicates dynamic tag/ref -> SHA resolution failed. ResolutionErrorTypeDynamicResolutionFailed ResolutionErrorType = "dynamic_resolution_failed" // ResolutionErrorTypePinNotFound indicates no usable hardcoded pin was found for the ref. ResolutionErrorTypePinNotFound ResolutionErrorType = "pin_not_found" )
type ResolutionFailure ¶ added in v0.69.1
type ResolutionFailure struct {
Repo string
Ref string
ErrorType ResolutionErrorType
}
ResolutionFailure captures an unresolved action-ref pinning event.
type SHAResolver ¶
SHAResolver resolves a GitHub Action's commit SHA for a given version tag.