diff options
Diffstat (limited to 'models/actions/run.go')
-rw-r--r-- | models/actions/run.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/models/actions/run.go b/models/actions/run.go index 498a73dc20..f0ab61b200 100644 --- a/models/actions/run.go +++ b/models/actions/run.go @@ -166,6 +166,17 @@ func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, err return nil, fmt.Errorf("event %s is not a pull request event", run.Event) } +func (run *ActionRun) GetWorkflowRunEventPayload() (*api.WorkflowRunPayload, error) { + if run.Event == webhook_module.HookEventWorkflowRun { + var payload api.WorkflowRunPayload + if err := json.Unmarshal([]byte(run.EventPayload), &payload); err != nil { + return nil, err + } + return &payload, nil + } + return nil, fmt.Errorf("event %s is not a workflow run event", run.Event) +} + func (run *ActionRun) IsSchedule() bool { return run.ScheduleID > 0 } |