ghactions

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package ghactions provides functions to locate action references and replace tags for checksums in GitHub Actions workflows.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAction is returned when parsing the action fails.
	ErrInvalidAction = fmt.Errorf("invalid action")
)

Functions

func GetChecksum

func GetChecksum(ctx context.Context, restIf interfaces.REST, action, ref string) (string, error)

GetChecksum returns the checksum for a given action and tag.

func IsLocal

func IsLocal(input string) bool

IsLocal returns true if the input is a local path.

func ModifyReferencesInYAML

func ModifyReferencesInYAML(ctx context.Context, restIf interfaces.REST, node *yaml.Node, cfg *config.GHActions) (bool, error)

ModifyReferencesInYAML takes the given YAML structure and replaces all references to tags with the checksum of the tag. Note that the given YAML structure is modified in-place. The function returns true if any references were modified.

func ModifyReferencesInYAMLWithCache added in v0.0.7

func ModifyReferencesInYAMLWithCache(
	ctx context.Context, restIf interfaces.REST, node *yaml.Node, cfg *config.GHActions, cache utils.RefCacher) (bool, error)

ModifyReferencesInYAMLWithCache takes the given YAML structure and replaces all references to tags with the checksum of the tag. Note that the given YAML structure is modified in-place. The function returns true if any references were modified. The function uses the provided cache to store the checksums.

func ParseActionReference

func ParseActionReference(input string) (action string, reference string, err error)

ParseActionReference parses an action reference into action and reference.

func TraverseGitHubActionWorkflows

func TraverseGitHubActionWorkflows(bfs billy.Filesystem, base string, fun TraverseGHWFunc) error

TraverseGitHubActionWorkflows traverses the GitHub Actions workflows in the given directory and calls the given function with each workflow.

Types

type Action added in v0.0.2

type Action struct {
	Action string `json:"action"`
	Owner  string `json:"owner"`
	Repo   string `json:"repo"`
	Ref    string `json:"ref"`
}

Action represents an action reference.

func ListActionsInDirectory added in v0.0.3

func ListActionsInDirectory(dir string) ([]Action, error)

ListActionsInDirectory returns a list of actions referenced in the given directory.

func ListActionsInYAML added in v0.0.2

func ListActionsInYAML(node *yaml.Node) ([]Action, error)

ListActionsInYAML returns a list of actions referenced in the given YAML structure.

type TraverseGHWFunc added in v0.0.5

type TraverseGHWFunc func(path string, wflow *yaml.Node) error

TraverseGHWFunc is a function that gets called with each file in a GitHub Actions workflow directory. It receives the path to the file and the parsed workflow.

Jump to

Keyboard shortcuts

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