Skip to content

Commit

Permalink
fix(deployments): set deployment created event action (#1087)
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Apr 11, 2024
1 parent 4fea679 commit ed4ab24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions scm/github/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ func (c *client) processDeploymentEvent(h *library.Hook, payload *github.Deploym
// convert payload to library build
b := new(library.Build)
b.SetEvent(constants.EventDeploy)
b.SetEventAction(constants.ActionCreated)
b.SetClone(repo.GetCloneURL())
b.SetDeploy(payload.GetDeployment().GetEnvironment())
b.SetDeployNumber(payload.GetDeployment().GetID())
Expand Down Expand Up @@ -427,6 +428,7 @@ func (c *client) processDeploymentEvent(h *library.Hook, payload *github.Deploym
// update the hook object
h.SetBranch(b.GetBranch())
h.SetEvent(constants.EventDeploy)
h.SetEventAction(constants.ActionCreated)
h.SetLink(
fmt.Sprintf("https://%s/%s/settings/hooks", h.GetHost(), r.GetFullName()),
)
Expand Down
12 changes: 8 additions & 4 deletions scm/github/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ func TestGithub_ProcessWebhook_Deployment(t *testing.T) {
wantHook.SetBranch("main")
wantHook.SetLink("https://github.com/Codertocat/Hello-World/settings/hooks")
wantHook.SetHost("github.com")
wantHook.SetEvent("deployment")
wantHook.SetEvent(constants.EventDeploy)
wantHook.SetEventAction(constants.ActionCreated)
wantHook.SetStatus(constants.StatusSuccess)

wantRepo := new(api.Repo)
Expand All @@ -588,7 +589,8 @@ func TestGithub_ProcessWebhook_Deployment(t *testing.T) {
wantRepo.SetTopics(nil)

wantBuild := new(library.Build)
wantBuild.SetEvent("deployment")
wantBuild.SetEvent(constants.EventDeploy)
wantBuild.SetEventAction(constants.ActionCreated)
wantBuild.SetClone("https://github.com/Codertocat/Hello-World.git")
wantBuild.SetDeploy("production")
wantBuild.SetDeployNumber(145988746)
Expand Down Expand Up @@ -707,7 +709,8 @@ func TestGithub_ProcessWebhook_Deployment_Commit(t *testing.T) {
wantHook.SetBranch("main")
wantHook.SetLink("https://github.com/Codertocat/Hello-World/settings/hooks")
wantHook.SetHost("github.com")
wantHook.SetEvent("deployment")
wantHook.SetEvent(constants.EventDeploy)
wantHook.SetEventAction(constants.ActionCreated)
wantHook.SetStatus(constants.StatusSuccess)

wantRepo := new(api.Repo)
Expand All @@ -721,7 +724,8 @@ func TestGithub_ProcessWebhook_Deployment_Commit(t *testing.T) {
wantRepo.SetTopics(nil)

wantBuild := new(library.Build)
wantBuild.SetEvent("deployment")
wantBuild.SetEvent(constants.EventDeploy)
wantBuild.SetEventAction(constants.ActionCreated)
wantBuild.SetClone("https://github.com/Codertocat/Hello-World.git")
wantBuild.SetDeploy("production")
wantBuild.SetDeployNumber(145988746)
Expand Down

0 comments on commit ed4ab24

Please sign in to comment.