Skip to content

Commit 9c33752

Browse files
authoredFeb 26, 2025
Disable commit comment by default (#1249)
1 parent 2fd50d3 commit 9c33752

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎internal/notification/client.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"os"
78

89
argocdv1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
910
"github.com/go-logr/logr"
@@ -51,10 +52,13 @@ func (c client) createComment(ctx context.Context, comment Comment, app argocdv1
5152
relatedPulls := filterPullRequestsRelatedToEvent(pulls, comment.SourceRevision, app)
5253
if len(relatedPulls) == 0 {
5354
logger.Info("No pull request related to the revision")
54-
if err := c.ghc.CreateCommitComment(ctx, comment.GitHubRepository, comment.SourceRevision.Revision, comment.Body); err != nil {
55-
return fmt.Errorf("unable to create a comment on revision %s: %w", comment.SourceRevision.Revision, err)
55+
// This may cause a secondary rate limit error of GitHub API.
56+
if os.Getenv("FEATURE_CREATE_COMMIT_COMMENT") == "true" {
57+
if err := c.ghc.CreateCommitComment(ctx, comment.GitHubRepository, comment.SourceRevision.Revision, comment.Body); err != nil {
58+
return fmt.Errorf("unable to create a comment on revision %s: %w", comment.SourceRevision.Revision, err)
59+
}
60+
logger.Info("Created a comment to the commit")
5661
}
57-
logger.Info("Created a comment to the commit")
5862
return nil
5963
}
6064

0 commit comments

Comments
 (0)