Documentation
¶
Index ¶
- type Action
- type Content
- type Workflow
- func (w *Workflow) BaseName() string
- func (w *Workflow) ExtractWorkflowEnv() map[string]bool
- func (w *Workflow) FindActions() ([]*Action, error)
- func (w *Workflow) FindJobLine(jobID string) int
- func (w *Workflow) FindStepLine(jobID string, stepIndex int) int
- func (w *Workflow) HasPermissions() bool
- func (w *Workflow) Lines() []string
- func (w *Workflow) NormalizeCommentSpacing() bool
- func (w *Workflow) Save() error
- func (w *Workflow) UpdateActionUses(oldUses, newUses, comment string) error
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 ¶
LoadWorkflow loads a single workflow file.
func LoadWorkflows ¶
LoadWorkflows loads all workflow files from the specified directory.
func (*Workflow) ExtractWorkflowEnv ¶
ExtractWorkflowEnv extracts workflow-level env variable names.
func (*Workflow) FindActions ¶
FindActions finds all GitHub Actions used in the workflow.
func (*Workflow) FindJobLine ¶
FindJobLine finds the line number where a job is defined.
func (*Workflow) FindStepLine ¶
FindStepLine finds the line number where a step is defined within a job.
func (*Workflow) HasPermissions ¶
HasPermissions returns true if the workflow has permissions configured.
func (*Workflow) NormalizeCommentSpacing ¶
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 ¶
Save writes the workflow to disk using the current RawBytes. This preserves original formatting including empty lines.
func (*Workflow) UpdateActionUses ¶
UpdateActionUses updates an action reference and optionally adds a comment. Uses line-based replacement to preserve original formatting including empty lines.