action/action.go (raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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 } |