workflow

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderUses

func RenderUses(actionStr, ref, srcRef, tail, quote string) string

RenderUses builds the replacement string for the matched span. If srcRef is empty, no trailing comment is emitted (and tail is dropped).

Types

type File

type File struct {
	Path          string
	Lines         []string
	TrailingNewln bool // whether the original file ended with a newline
	Mode          os.FileMode
}

File is the contents of a workflow file, split into lines without their terminating newline (and with \r preserved for CRLF inputs).

func Read

func Read(path string) (*File, error)

Read loads a workflow file into memory.

func (*File) FindAllUses

func (f *File) FindAllUses() []UsesMatch

FindAllUses returns every `uses:` match across the file.

func (*File) HasWorkflowMarker

func (f *File) HasWorkflowMarker() bool

HasWorkflowMarker reports whether any line begins with `on:` or `jobs:` at the start of the line (after optional whitespace). Mirrors legacy.

func (*File) ReplaceMatch

func (f *File) ReplaceMatch(m UsesMatch, repl string)

ReplaceMatch swaps the substring at m's span in the corresponding line with `repl`. Safe to call for one match at a time; if you have multiple matches on the same line, apply right-to-left to keep offsets valid.

func (*File) Write

func (f *File) Write() error

Write persists the file using the original mode and newline convention.

type UsesMatch

type UsesMatch struct {
	LineIndex int        // 0-based
	Start     int        // byte offset in line where match begins
	End       int        // byte offset where match ends (exclusive)
	Quote     string     // optional quote style around the uses value: ' or "
	Action    action.Ref // parsed action ref
}

UsesMatch is one `uses:` occurrence within a single line.

func FindUses

func FindUses(line string, lineIdx int) (UsesMatch, bool)

FindUses scans a single line. Returns the match if the line has a pinnable `uses:` directive, ok=false otherwise.

Jump to

Keyboard shortcuts

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