Feature: Support workflow event dispatch via API (#33545)
Fix: https://github.com/go-gitea/gitea/issues/31765 (Re-open #32059) --------- Co-authored-by: Bence Santha <git@santha.eu> Co-authored-by: Bence Sántha <7604637+bencurio@users.noreply.github.com> Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
This commit is contained in:
parent
085f273d19
commit
30993e9508
13 changed files with 1748 additions and 148 deletions
|
@ -32,3 +32,36 @@ type ActionTaskResponse struct {
|
|||
Entries []*ActionTask `json:"workflow_runs"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
||||
// CreateActionWorkflowDispatch represents the payload for triggering a workflow dispatch event
|
||||
// swagger:model
|
||||
type CreateActionWorkflowDispatch struct {
|
||||
// required: true
|
||||
// example: refs/heads/main
|
||||
Ref string `json:"ref" binding:"Required"`
|
||||
// required: false
|
||||
Inputs map[string]string `json:"inputs,omitempty"`
|
||||
}
|
||||
|
||||
// ActionWorkflow represents a ActionWorkflow
|
||||
type ActionWorkflow struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
State string `json:"state"`
|
||||
// swagger:strfmt date-time
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
// swagger:strfmt date-time
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
URL string `json:"url"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
BadgeURL string `json:"badge_url"`
|
||||
// swagger:strfmt date-time
|
||||
DeletedAt time.Time `json:"deleted_at,omitempty"`
|
||||
}
|
||||
|
||||
// ActionWorkflowResponse returns a ActionWorkflow
|
||||
type ActionWorkflowResponse struct {
|
||||
Workflows []*ActionWorkflow `json:"workflows"`
|
||||
TotalCount int64 `json:"total_count"`
|
||||
}
|
||||
|
|
|
@ -36,6 +36,22 @@ func (w SilentWrap) Unwrap() error {
|
|||
return w.Err
|
||||
}
|
||||
|
||||
type LocaleWrap struct {
|
||||
err error
|
||||
TrKey string
|
||||
TrArgs []any
|
||||
}
|
||||
|
||||
// Error returns the message
|
||||
func (w LocaleWrap) Error() string {
|
||||
return w.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap returns the underlying error
|
||||
func (w LocaleWrap) Unwrap() error {
|
||||
return w.err
|
||||
}
|
||||
|
||||
// NewSilentWrapErrorf returns an error that formats as the given text but unwraps as the provided error
|
||||
func NewSilentWrapErrorf(unwrap error, message string, args ...any) error {
|
||||
if len(args) == 0 {
|
||||
|
@ -63,3 +79,16 @@ func NewAlreadyExistErrorf(message string, args ...any) error {
|
|||
func NewNotExistErrorf(message string, args ...any) error {
|
||||
return NewSilentWrapErrorf(ErrNotExist, message, args...)
|
||||
}
|
||||
|
||||
// ErrWrapLocale wraps an err with a translation key and arguments
|
||||
func ErrWrapLocale(err error, trKey string, trArgs ...any) error {
|
||||
return LocaleWrap{err: err, TrKey: trKey, TrArgs: trArgs}
|
||||
}
|
||||
|
||||
func ErrAsLocale(err error) *LocaleWrap {
|
||||
var e LocaleWrap
|
||||
if errors.As(err, &e) {
|
||||
return &e
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue