Help us shape the future of Go! Take the 2026 Go Developer Survey

workflow

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Uses string     // Action reference (e.g., "actions/checkout@v3")
	Line int        // Line number in the YAML file
	Node *yaml.Node // YAML node reference for updates
}

Action represents a GitHub Action usage in a workflow file.

type Content

type Content struct {
	Name        string         `yaml:"name"`
	On          any            `yaml:"on"`
	Jobs        map[string]any `yaml:"jobs"`
	Permissions any            `yaml:"permissions"`
}

Content represents the parsed structure of a GitHub Actions workflow.

type Workflow

type Workflow struct {
	File     string   // Path to the workflow file
	Content  *Content // Parsed workflow structure
	RawBytes []byte   // Raw YAML bytes for manipulation
	// contains filtered or unexported fields
}

Workflow represents a GitHub Actions workflow file.

func LoadWorkflow

func LoadWorkflow(path string) (*Workflow, error)

LoadWorkflow loads a single workflow file.

func LoadWorkflows

func LoadWorkflows(dir string) ([]*Workflow, error)

LoadWorkflows loads all workflow files from the specified directory.

func (*Workflow) BaseName

func (w *Workflow) BaseName() string

BaseName returns the base name of the workflow file.

func (*Workflow) ExtractWorkflowEnv

func (w *Workflow) ExtractWorkflowEnv() map[string]bool

ExtractWorkflowEnv extracts workflow-level env variable names.

func (*Workflow) FindActions

func (w *Workflow) FindActions() ([]*Action, error)

FindActions finds all GitHub Actions used in the workflow.

func (*Workflow) FindJobLine

func (w *Workflow) FindJobLine(jobID string) int

FindJobLine finds the line number where a job is defined.

func (*Workflow) FindStepLine

func (w *Workflow) FindStepLine(jobID string, stepIndex int) int

FindStepLine finds the line number where a step is defined within a job.

func (*Workflow) HasPermissions

func (w *Workflow) HasPermissions() bool

HasPermissions returns true if the workflow has permissions configured.

func (*Workflow) Lines

func (w *Workflow) Lines() []string

Lines returns the workflow content as individual lines.

func (*Workflow) NormalizeCommentSpacing

func (w *Workflow) NormalizeCommentSpacing() bool

NormalizeCommentSpacing normalizes spacing before version tag comments on uses: lines. Only affects comments that look like version tags (e.g., "# v1.0.0"). Ensures exactly 1 space before the # character.

func (*Workflow) Save

func (w *Workflow) Save() error

Save writes the workflow to disk using the current RawBytes. This preserves original formatting including empty lines.

func (*Workflow) UpdateActionUses

func (w *Workflow) UpdateActionUses(oldUses, newUses, comment string) error

UpdateActionUses updates an action reference and optionally adds a comment. Uses line-based replacement to preserve original formatting including empty lines.

Jump to

Keyboard shortcuts

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