Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: github pr close evnt (#11595)
ecmadao6b8a7a370fbd
diff --git a/backend/api/gitops/github.go b/backend/api/gitops/github.goindex 43530258d1..a7e9a64de6 100644--- a/backend/api/gitops/github.go+++ b/backend/api/gitops/github.go@@ -22,8 +22,8 @@ func getGitHubPullRequestInfo(ctx context.Context, vcsProvider *store.VCSProvideif err := json.Unmarshal(body, &pushEvent); err != nil {return nil, errors.Errorf("failed to unmarshal push event, error %v", err)}- if pushEvent.Action != closeAction {- return nil, errors.Errorf("skip webhook event action, got %s, want closed", pushEvent.Action)+ if pushEvent.Action != closeAction || !pushEvent.PullRequest.Merged {+ return nil, errors.Errorf("skip webhook event action, got %s, want closed with merged", pushEvent.Action)}if pushEvent.PullRequest.Base.Ref != vcsConnector.Payload.Branch {diff --git a/backend/plugin/vcs/github/webhook_events.go b/backend/plugin/vcs/github/webhook_events.goindex 60ed881440..5d160e69f9 100644--- a/backend/plugin/vcs/github/webhook_events.go+++ b/backend/plugin/vcs/github/webhook_events.go@@ -3,6 +3,7 @@ package github// PullRequestPushEvent is the json message for pull request push event.type PullRequestPushEvent struct {// opened, edited, closed.+ // PR close will also send webhook event with "closed" action, so we need to check the "merged" field.Action string `json:"action"`Number int `json:"number"`PullRequest EventPullRequest `json:"pull_request"`@@ -14,6 +15,7 @@ type EventPullRequest struct {Body string `json:"body"`Base EventBranch `json:"base"`Head EventBranch `json:"head"`+ Merged bool `json:"merged"`}type EventBranch struct {diff --git a/backend/tests/vcs_test.go b/backend/tests/vcs_test.goindex d8deb52edf..8fb1253683 100644--- a/backend/tests/vcs_test.go+++ b/backend/tests/vcs_test.go@@ -88,6 +88,7 @@ func TestVCS(t *testing.T) {Ref: "test-branch",SHA: "cc63b0592388a7ab1b05b005ad8c8dc14ce432b1",},+ Merged: true,},},},