From 331e878e81d57235a53199383087c7649797a887 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 6 Nov 2024 22:41:49 -0800 Subject: Add new event commit status creation and webhook implementation (#27151) This PR introduces a new event which is similar as Github's. When a new commit status submitted, the event will be trigged. That means, now we can receive all feedback from CI/CD system in webhooks or other notify systems. ref: https://docs.github.com/en/webhooks/webhook-events-and-payloads#status Fix #20749 --- modules/structs/hook.go | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'modules/structs') diff --git a/modules/structs/hook.go b/modules/structs/hook.go index db8b20e7e5..ce5742e5c7 100644 --- a/modules/structs/hook.go +++ b/modules/structs/hook.go @@ -262,13 +262,6 @@ func (p *ReleasePayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") } -// __________ .__ -// \______ \__ __ _____| |__ -// | ___/ | \/ ___/ | \ -// | | | | /\___ \| Y \ -// |____| |____//____ >___| / -// \/ \/ - // PushPayload represents a payload information of push event. type PushPayload struct { Ref string `json:"ref"` @@ -509,3 +502,26 @@ type WorkflowDispatchPayload struct { func (p *WorkflowDispatchPayload) JSONPayload() ([]byte, error) { return json.MarshalIndent(p, "", " ") } + +// CommitStatusPayload represents a payload information of commit status event. +type CommitStatusPayload struct { + // TODO: add Branches per https://docs.github.com/en/webhooks/webhook-events-and-payloads#status + Commit *PayloadCommit `json:"commit"` + Context string `json:"context"` + // swagger:strfmt date-time + CreatedAt time.Time `json:"created_at"` + Description string `json:"description"` + ID int64 `json:"id"` + Repo *Repository `json:"repository"` + Sender *User `json:"sender"` + SHA string `json:"sha"` + State string `json:"state"` + TargetURL string `json:"target_url"` + // swagger:strfmt date-time + UpdatedAt *time.Time `json:"updated_at"` +} + +// JSONPayload implements Payload +func (p *CommitStatusPayload) JSONPayload() ([]byte, error) { + return json.MarshalIndent(p, "", " ") +} -- cgit v1.2.3