diff --git a/server/events/command_runner.go b/server/events/command_runner.go index c00853475..90d4e1c52 100644 --- a/server/events/command_runner.go +++ b/server/events/command_runner.go @@ -273,7 +273,8 @@ func (c *DefaultCommandRunner) RunCommentCommand(baseRepo models.Repo, maybeHead c.updateCommitStatus(ctx, cmd.Name, pullStatus) - if cmd.Name == models.ApplyCommand && c.automergeEnabled(ctx, projectCmds) { + // Do not automerge if no commands were executed at all, or if there have been errors + if cmd.Name == models.ApplyCommand && c.automergeEnabled(ctx, projectCmds) && len(projectCmds) > 0 && !result.HasErrors() { c.automerge(ctx, pullStatus) } }