API Reference
The GitHub Action Parser library provides a comprehensive set of types and functions for parsing, validating, and processing GitHub Action and Workflow YAML files.
Package Overview
go
import "github.com/scagogogo/github-action-parser/pkg/parser"
The parser
package contains all the functionality needed to work with GitHub Actions and Workflows:
- Core Types: Data structures representing GitHub Action and Workflow components
- Parser Functions: Functions to parse YAML files and directories
- Validation: Tools to validate parsed files according to GitHub specifications
- Utilities: Helper functions for type conversion and data processing
Quick Reference
Main Functions
Function | Description |
---|---|
ParseFile(path string) | Parse a single YAML file |
Parse(r io.Reader) | Parse from an io.Reader |
ParseDir(dir string) | Parse all YAML files in a directory |
NewValidator() | Create a new validator instance |
Core Types
Type | Description |
---|---|
ActionFile | Main structure representing an action or workflow |
Input | Input parameter definition |
Output | Output parameter definition |
Job | Workflow job definition |
Step | Individual step in a job |
RunsConfig | Action execution configuration |
Validation Types
Type | Description |
---|---|
Validator | Validator for GitHub Action specifications |
ValidationError | Validation error information |
Utility Types
Type | Description |
---|---|
StringOrStringSlice | Flexible string/array type for YAML |
Error Handling
All parsing functions return errors that provide detailed information about parsing failures:
go
action, err := parser.ParseFile("action.yml")
if err != nil {
// Handle parsing error
fmt.Printf("Failed to parse: %v\n", err)
return
}
Validation errors are returned as a slice of ValidationError
structs:
go
validator := parser.NewValidator()
errors := validator.Validate(action)
for _, err := range errors {
fmt.Printf("Field %s: %s\n", err.Field, err.Message)
}
Type Safety
The library provides full type safety for all GitHub Action and Workflow structures. All fields are properly typed according to the GitHub Actions specification, with appropriate use of pointers for optional fields and interfaces for flexible data types.
Performance
The parser is optimized for performance and can efficiently handle:
- Large action and workflow files
- Batch processing of multiple files
- Recursive directory parsing
- Memory-efficient processing of large repositories
Next Steps
- Types Reference - Detailed documentation of all data structures
- Parser Functions - Complete parsing API documentation
- Validation - Validation features and error handling
- Utilities - Helper functions and utilities