aboutsummaryrefslogtreecommitdiffstats
path: root/modules/structs/hook.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-11-06 22:41:49 -0800
committerGitHub <noreply@github.com>2024-11-07 06:41:49 +0000
commit331e878e81d57235a53199383087c7649797a887 (patch)
tree736485bdb5b49956022587506315b652076cff2f /modules/structs/hook.go
parent145e26698791221b007c7dd460fb506cb0237235 (diff)
downloadgitea-331e878e81d57235a53199383087c7649797a887.tar.gz
gitea-331e878e81d57235a53199383087c7649797a887.zip
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
Diffstat (limited to 'modules/structs/hook.go')
-rw-r--r--modules/structs/hook.go30
1 files changed, 23 insertions, 7 deletions
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, "", " ")
+}