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
This commit is contained in:
Lunny Xiao 2024-11-06 22:41:49 -08:00 committed by GitHub
parent 145e266987
commit 331e878e81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 90 additions and 22 deletions

View file

@ -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, "", " ")
}