mirror of
https://gitea.com/gitea/act
synced 2026-05-12 12:01:13 +02:00
fix v4 upgrade
This commit is contained in:
@@ -50,17 +50,18 @@ func (w *SingleWorkflow) SetJob(id string, job *Job) error {
|
|||||||
m := map[string]*Job{
|
m := map[string]*Job{
|
||||||
id: job,
|
id: job,
|
||||||
}
|
}
|
||||||
buf, err := yaml.Marshal(m)
|
var buf bytes.Buffer
|
||||||
if err != nil {
|
encoder := yaml.NewEncoder(&buf)
|
||||||
return err
|
encoder.SetIndent(2)
|
||||||
}
|
encoder.Encode(m)
|
||||||
|
encoder.Close()
|
||||||
|
|
||||||
node := yaml.Node{}
|
node := yaml.Node{}
|
||||||
if err := yaml.Unmarshal(buf, &node); err != nil {
|
if err := yaml.Unmarshal(buf.Bytes(), &node); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(node.Content) != 1 || node.Content[0].Kind != yaml.MappingNode {
|
if len(node.Content) != 1 || node.Content[0].Kind != yaml.MappingNode {
|
||||||
return fmt.Errorf("can not set job: %s", string(buf))
|
return fmt.Errorf("can not set job: %s", buf.String())
|
||||||
}
|
}
|
||||||
w.RawJobs = *node.Content[0]
|
w.RawJobs = *node.Content[0]
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user