Skip to content

Commit

Permalink
Don't alert on successful rules.
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Antonio Osorio <[email protected]>
  • Loading branch information
JAORMX committed Dec 18, 2024
1 parent 3d82226 commit fb5d46d
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ type PrCommentTemplateParams struct {
}

type paramsPR struct {
Title string
Comment string
props *properties.Properties
Metadata *provifv1.CommentResultMeta
prevStatus *db.ListRuleEvaluationsByProfileIdRow
Title string
Comment string
props *properties.Properties
Metadata *provifv1.CommentResultMeta
prevStatus *db.ListRuleEvaluationsByProfileIdRow
shouldAlert bool
}

// NewPullRequestCommentAlert creates a new pull request comment alert action
Expand Down Expand Up @@ -196,7 +197,7 @@ func (alert *Alert) runDoReview(ctx context.Context, params *paramsPR) (json.Raw
}

// This was a successful result, so we don't need to alert
if params.Comment == "" {
if !params.shouldAlert {
return json.RawMessage("{}"), nil
}

Expand Down Expand Up @@ -225,8 +226,9 @@ func (alert *Alert) getParamsForPRComment(
}

result := &paramsPR{
prevStatus: params.GetEvalStatusFromDb(),
props: props,
prevStatus: params.GetEvalStatusFromDb(),
props: props,
shouldAlert: params.GetEvalErr() != nil,
}

commentTmpl, err := util.NewSafeHTMLTemplate(&alert.reviewCfg.ReviewMessage, "message")
Expand Down

0 comments on commit fb5d46d

Please sign in to comment.