package action import ( "fmt" "os" "gopkg.in/yaml.v3" ) type Action struct { Build struct { Cmd string `yaml:"cmd"` } `yaml:"build,omitempty"` Deploy struct { Hosts []string `yaml:"hosts"` Artifacts map[string][]string `yaml:"artifacts"` Before map[string]string `yaml:"before,omitempty"` After map[string]string `yaml:"after,omitempty"` } `yaml:"deploy,omitempty"` } func Read(filename string) (*Action, error) { b, err := os.ReadFile(filename) if err != nil { return nil, fmt.Errorf("reading action: %w", err) } a := Action{} if err := yaml.Unmarshal(b, &a); err != nil { return nil, fmt.Errorf("parsing action: %w", err) } return &a, nil }