workflow

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(w *Workflow) error

Write serializes the workflow's modified AST back to disk, preserving original whitespace by patching only changed values.

Types

type ActionRef

type ActionRef struct {
	Owner string // e.g. "actions"
	Repo  string // e.g. "checkout"
	Path  string // e.g. "" or "/subdir"
	Ref   string // e.g. "v4" or a full SHA
	Node  *yaml.Node
}

ActionRef is a parsed `uses:` value like "actions/checkout@v4".

func CollectActions

func CollectActions(w *Workflow) []*ActionRef

CollectActions returns all unique action references from a workflow.

func (*ActionRef) Full

func (a *ActionRef) Full() string

Full returns "owner/repo" (with optional path).

func (*ActionRef) IsSHA

func (a *ActionRef) IsSHA() bool

IsSHA returns true when the ref is already a 40-character hex SHA.

func (*ActionRef) String

func (a *ActionRef) String() string

String returns the full uses value like "actions/checkout@v4".

type Job

type Job struct {
	ID          string
	Node        *yaml.Node
	Permissions *Permissions
	Steps       []Step
}

Job is a single job inside the workflow.

type NodeSnapshot added in v0.3.0

type NodeSnapshot struct {
	Value       string
	LineComment string
}

NodeSnapshot stores the original value of a yaml.Node at parse time.

type Permissions

type Permissions struct {
	Node    *yaml.Node
	IsEmpty bool              // true when the key is absent
	Values  map[string]string // e.g. {"contents": "read", "packages": "write"}
	IsAll   bool              // true when set to a bare string like "write-all"
}

Permissions models the top-level or job-level "permissions" block.

type Step

type Step struct {
	Name string
	Uses *ActionRef // nil when the step is a `run:` step
	Node *yaml.Node
}

Step represents one step inside a job.

type Workflow

type Workflow struct {
	Path      string // filesystem path to the YAML file
	Raw       []byte // original bytes from disk
	Doc       yaml.Node
	Snapshots map[*yaml.Node]NodeSnapshot // original node values

	Permissions *Permissions
	Jobs        []Job
}

Workflow represents a parsed GitHub Actions workflow file.

func Parse

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

Parse reads a workflow YAML file and returns a Workflow.

Jump to

Keyboard shortcuts

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