diff --git a/api/build/restart.go b/api/build/restart.go index 213f263db..d819c1805 100644 --- a/api/build/restart.go +++ b/api/build/restart.go @@ -340,13 +340,13 @@ func RestartBuild(c *gin.Context) { c.JSON(http.StatusCreated, b) // if the event is a deployment, update the build list - if !strings.EqualFold(b.GetEvent(), constants.EventDeploy) { + if strings.EqualFold(b.GetEvent(), constants.EventDeploy) { d, err := database.FromContext(c).GetDeploymentForRepo(c, r, b.GetDeployNumber()) if err != nil { logger.Errorf("unable to set get deployment for build %s: %v", entry, err) } - build := append(d.Builds, b) + build := append(d.GetBuilds(), b) d.SetBuilds(build) diff --git a/api/webhook/post.go b/api/webhook/post.go index 4414c8da9..7d44689fe 100644 --- a/api/webhook/post.go +++ b/api/webhook/post.go @@ -666,7 +666,7 @@ func PostWebhook(c *gin.Context) { // set the BuildID field h.SetBuildID(b.GetID()) // if event is deployment, update the deployment record to include this build - if !strings.EqualFold(b.GetEvent(), constants.EventDeploy) { + if strings.EqualFold(b.GetEvent(), constants.EventDeploy) { d, err := database.FromContext(c).GetDeploymentForRepo(c, repo, webhook.Deployment.GetNumber()) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { @@ -695,7 +695,8 @@ func PostWebhook(c *gin.Context) { return } } else { - d.SetBuilds([]*library.Build{b}) + build := append(d.GetBuilds(), b) + d.SetBuilds(build) _, err := database.FromContext(c).UpdateDeployment(d) if err != nil { retErr := fmt.Errorf("%s: failed to update deployment %s/%d: %w", baseErr, repo.GetFullName(), d.GetNumber(), err)