1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-06 17:40:58 +00:00

feat: add notifications control to the workflow (#151)

Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/151
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-06-14 15:42:32 +00:00 committed by earl-warren
parent 5cf8d53087
commit 01032808ea
2 changed files with 77 additions and 0 deletions

View file

@ -21,6 +21,8 @@ type Workflow struct {
Env map[string]string `yaml:"env"`
Jobs map[string]*Job `yaml:"jobs"`
Defaults Defaults `yaml:"defaults"`
RawNotifications yaml.Node `yaml:"notifications"`
}
// On events for the workflow
@ -761,3 +763,19 @@ func decodeNode(node yaml.Node, out interface{}) bool {
}
return true
}
func (w *Workflow) Notifications() (bool, error) {
switch w.RawNotifications.Kind {
case 0:
return false, nil
case yaml.ScalarNode:
var val bool
err := w.RawNotifications.Decode(&val)
if err != nil {
return false, fmt.Errorf("notifications: failed to decode: %v", w.RawNotifications.Kind)
}
return val, nil
default:
return false, fmt.Errorf("notifications: unknown type: %v", w.RawNotifications.Kind)
}
}