Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deployments): set deployment created event action #1087

Merged
merged 9 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/adhocore/gronx v1.8.1
github.com/alicebob/miniredis/v2 v2.32.1
github.com/aws/aws-sdk-go v1.51.0
github.com/buildkite/yaml v0.0.0-20181016232759-0caa5f0796e3
github.com/buildkite/yaml v0.0.0-20230306222819-0e4e032d4835
plyr4 marked this conversation as resolved.
Show resolved Hide resolved
github.com/drone/envsubst v1.0.3
github.com/gin-gonic/gin v1.9.1
github.com/go-playground/assert/v2 v2.2.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/buildkite/yaml v0.0.0-20181016232759-0caa5f0796e3 h1:q+sMKdA6L8LyGVudTkpGoC73h6ak2iWSPFiFo/pFOU8=
github.com/buildkite/yaml v0.0.0-20181016232759-0caa5f0796e3/go.mod h1:5hCug3EZaHXU3FdCA3gJm0YTNi+V+ooA2qNTiVpky4A=
github.com/buildkite/yaml v0.0.0-20230306222819-0e4e032d4835 h1:Zfkih+Opdv9y5AOob+8iMsaMYnans+Ozrkb8wiPHbj0=
github.com/buildkite/yaml v0.0.0-20230306222819-0e4e032d4835/go.mod h1:AV5wtJnn1/CRaRGlJ8xspkMWfKXV0/pkJVgGleTIrfk=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s=
github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
Expand Down
2 changes: 2 additions & 0 deletions scm/github/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,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 @@ -426,6 +427,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 @@ -573,7 +573,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(library.Repo)
Expand All @@ -587,7 +588,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 @@ -706,7 +708,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(library.Repo)
Expand All @@ -720,7 +723,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
Loading