@@ -50,6 +50,9 @@ func (s *webhookService) Parse(req *http.Request, fn scm.SecretFunc) (scm.Webhoo
5050 hook , err = s .parseReleaseHook (data )
5151 case "workflow_run" :
5252 hook , err = s .parsePipelineHook (data )
53+ case "pull_request_review" :
54+ hook , err = s .parsePullRequestReviewHook (data )
55+
5356 default :
5457 return nil , scm .ErrUnknownEvent
5558 }
@@ -184,6 +187,26 @@ func (s *webhookService) parsePullRequestHook(data []byte) (scm.Webhook, error)
184187 return dst , nil
185188}
186189
190+ func (s * webhookService ) parsePullRequestReviewHook (data []byte ) (scm.Webhook , error ) {
191+ src := new (pullRequestReviewHook )
192+ err := json .Unmarshal (data , src )
193+ if err != nil {
194+ return nil , err
195+ }
196+ dst := convertPullRequestReviewHook (src )
197+ switch src .Action {
198+ case "submitted" :
199+ dst .Action = scm .ActionCreate
200+ case "edited" :
201+ dst .Action = scm .ActionUpdate
202+ case "dismissed" :
203+ dst .Action = scm .ActionDelete
204+ default :
205+ dst .Action = scm .ActionUnknown
206+ }
207+ return dst , nil
208+ }
209+
187210func (s * webhookService ) parsePipelineHook (data []byte ) (scm.Webhook , error ) {
188211 src := new (pipelineHook )
189212 err := json .Unmarshal (data , src )
@@ -358,6 +381,14 @@ type (
358381 Sender user `json:"sender"`
359382 }
360383
384+ pullRequestReviewHook struct {
385+ Action string `json:"action"`
386+ Number int `json:"number"`
387+ PullRequest pr `json:"pull_request"`
388+ Repository repository `json:"repository"`
389+ Sender user `json:"sender"`
390+ }
391+
361392 // github deployment webhook payload
362393 deploymentHook struct {
363394 Deployment struct {
@@ -615,6 +646,15 @@ func convertPullRequestHook(src *pullRequestHook) *scm.PullRequestHook {
615646 }
616647}
617648
649+ func convertPullRequestReviewHook (src * pullRequestReviewHook ) * scm.PullRequestReviewHook {
650+ return & scm.PullRequestReviewHook {
651+ // Action Action
652+ Repo : * convertRepository (& src .Repository ),
653+ PullRequest : * convertPullRequest (& src .PullRequest ),
654+ Sender : * convertUser (& src .Sender ),
655+ }
656+ }
657+
618658func convertDeploymentHook (src * deploymentHook ) * scm.DeployHook {
619659 dst := & scm.DeployHook {
620660 Number : src .Deployment .ID ,
0 commit comments