mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-01 14:56:30 +00:00
46 lines
874 B
Go
46 lines
874 B
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package projects
|
|
|
|
// Action represents an action that can be taken in a workflow
|
|
type Action struct {
|
|
SetValue string
|
|
}
|
|
|
|
const (
|
|
// Project workflow event names
|
|
EventItemAddedToProject = "item_added_to_project"
|
|
EventItemClosed = "item_closed"
|
|
)
|
|
|
|
type Event struct {
|
|
Name string
|
|
Types []string
|
|
Actions []Action
|
|
}
|
|
|
|
type Workflow struct {
|
|
Name string
|
|
Events []Event
|
|
}
|
|
|
|
func ParseWorkflow(content string) (*Workflow, error) {
|
|
return &Workflow{}, nil
|
|
}
|
|
|
|
func (w *Workflow) FireAction(evtName string, f func(action Action) error) error {
|
|
for _, evt := range w.Events {
|
|
if evt.Name == evtName {
|
|
for _, action := range evt.Actions {
|
|
// Do something with action
|
|
if err := f(action); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
break
|
|
}
|
|
}
|
|
return nil
|
|
}
|