Skip to content

Commit

Permalink
fix: add tag event
Browse files Browse the repository at this point in the history
Signed-off-by: Gosha <[email protected]>
  • Loading branch information
gosharo committed Sep 5, 2023
1 parent de2d290 commit 9aec7a4
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions pkg/git_provider/bitbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,28 @@ func (b BitbucketClientImpl) HandlePayload(ctx *context.Context, request *http.R
// https://support.atlassian.com/bitbucket-cloud/docs/event-payloads
switch request.Header.Get("X-Event-Key") {
case "repo:push":
webhookPayload = &WebhookPayload{
Event: "push",
Repo: utils.SanitizeString(gjson.GetBytes(buf.Bytes(), "repository.name").Value().(string)),
Branch: gjson.GetBytes(buf.Bytes(), "push.changes.0.new.name").Value().(string),
Commit: gjson.GetBytes(buf.Bytes(), "push.changes.0.commits.0.hash").Value().(string),
UserEmail: utils.ExtractStringsBetweenTags(gjson.GetBytes(buf.Bytes(), "push.changes.0.commits.0.author.raw").Value().(string))[0],
User: gjson.GetBytes(buf.Bytes(), "actor.display_name").Value().(string),
HookID: hookID,
switch gjson.GetBytes(buf.Bytes(), "push.changes.0.new.type").Value().(string) {
case "tag":
webhookPayload = &WebhookPayload{
Event: "tag",
Repo: utils.SanitizeString(gjson.GetBytes(buf.Bytes(), "repository.name").Value().(string)),
Branch: gjson.GetBytes(buf.Bytes(), "push.changes.0.new.name").Value().(string),
Commit: gjson.GetBytes(buf.Bytes(), "push.changes.0.new.name").Value().(string),
User: gjson.GetBytes(buf.Bytes(), "actor.display_name").Value().(string),
HookID: hookID,
}
default:
webhookPayload = &WebhookPayload{
Event: "push",
Repo: utils.SanitizeString(gjson.GetBytes(buf.Bytes(), "repository.name").Value().(string)),
Branch: gjson.GetBytes(buf.Bytes(), "push.changes.0.new.name").Value().(string),
Commit: gjson.GetBytes(buf.Bytes(), "push.changes.0.commits.0.hash").Value().(string),
UserEmail: utils.ExtractStringsBetweenTags(gjson.GetBytes(buf.Bytes(), "push.changes.0.commits.0.author.raw").Value().(string))[0],
User: gjson.GetBytes(buf.Bytes(), "actor.display_name").Value().(string),
HookID: hookID,
}
}

case "pullrequest:created", "pullrequest:updated":
webhookPayload = &WebhookPayload{
Event: "pull_request",
Expand Down

0 comments on commit 9aec7a4

Please sign in to comment.