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:
parent
5cf8d53087
commit
01032808ea
2 changed files with 77 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue