From 9d4db5a25bc11d38518e715723257d98cd2ff1b7 Mon Sep 17 00:00:00 2001 From: Luca Corrieri Date: Sat, 4 Nov 2023 17:12:08 +0100 Subject: [PATCH] fix(github): handle reopened PR --- internal/webhook/github/provider.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/webhook/github/provider.go b/internal/webhook/github/provider.go index d8f9c067..1c7ec2af 100644 --- a/internal/webhook/github/provider.go +++ b/internal/webhook/github/provider.go @@ -70,7 +70,7 @@ func (g *Github) GetEvent(r *http.Request) (event.Event, error) { ID: strconv.FormatInt(payload.PullRequest.Number, 10), URL: event.NormalizeUrl(payload.Repository.HTMLURL), Revision: payload.PullRequest.Head.Ref, - Action: payload.Action, + Action: getNormalizedAction(payload.Action), Base: payload.PullRequest.Base.Ref, Commit: payload.PullRequest.Head.Sha, } @@ -79,3 +79,14 @@ func (g *Github) GetEvent(r *http.Request) (event.Event, error) { } return e, nil } + +func getNormalizedAction(action string) string { + switch action { + case "opened", "reopened": + return event.PullRequestOpened + case "closed": + return event.PullRequestClosed + default: + return action + } +}