Skip to content

Commit 6906909

Browse files
committed
matrix strategy parsing
1 parent 9d48684 commit 6906909

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

models/github_actions.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ type GithubActionsJob struct {
172172
Env GithubActionsEnvs `json:"env,omitempty"`
173173
Steps GithubActionsSteps `json:"steps"`
174174
ReferencesSecrets []string `json:"references_secrets" yaml:"-"`
175+
Strategy GithubActionsStrategy `json:"strategy,omitempty" yaml:"strategy"`
175176
Line int `json:"line" yaml:"-"`
176177

177178
Lines map[string]int `json:"lines" yaml:"-"`
@@ -545,3 +546,26 @@ func (o *GithubActionsJobEnvironments) UnmarshalYAML(node *yaml.Node) error {
545546
*o = GithubActionsJobEnvironments{env}
546547
return nil
547548
}
549+
550+
type GithubActionsStrategy struct {
551+
Matrix map[string]StringList `json:"matrix,omitempty" yaml:"matrix"`
552+
}
553+
554+
// UnmarshalYAML parses the `strategy` block and extracts `matrix`
555+
func (o *GithubActionsStrategy) UnmarshalYAML(node *yaml.Node) error {
556+
if node.Kind != yaml.MappingNode {
557+
return fmt.Errorf("invalid yaml node type for strategy")
558+
}
559+
for i := 0; i < len(node.Content); i += 2 {
560+
key := node.Content[i].Value
561+
value := node.Content[i+1]
562+
if key == "matrix" {
563+
var m map[string]StringList
564+
if err := value.Decode(&m); err != nil {
565+
return err
566+
}
567+
o.Matrix = m
568+
}
569+
}
570+
return nil
571+
}

0 commit comments

Comments
 (0)