Skip to content

feat(github): enhance pullRequestComment with folding support and templateable commentTag #433

@xakraz

Description

@xakraz

Feature Request

Problem Statement

The current github.pullRequestComment notification in argoproj/notifications-engine provides a commentTag option to identify and upsert comments on PRs. However, this comes with two significant limitations:

  1. No comment folding/collapsing support: When not using commentTag, or even when using it, there is no native way to mark a comment as minimized/outdated. Tools like marocchino/sticky-pull-request-comment expose options such as hide: true, hide_and_recreate: true, and hide_classify to minimize old comments via GitHub's API. No equivalent exists in notifications-engine.

  2. commentTag is not templateable: The commentTag field value is used as a static string (it is not rendered through the Go template engine). This means that when multiple Argo CD Applications are associated with the same PR, they all share the same commentTag, causing their comments to override each other — only the last notification "wins". There is currently no way to include dynamic values (e.g., the application name) in the tag to make it unique per Application.

Current Behavior

  • GitHubPullRequestComment.CommentTag is a static string set once at template definition time (pkg/services/github.go).
  • When a commentTag is provided, the engine searches for a comment containing <!-- argocd-notifications <tag> --> and updates it in-place, or creates a new one.
  • Old/stale comments are never hidden or minimized.
  • No mechanism exists to differentiate comments from multiple Applications on the same PR.

Proposed Solutions

1. Make commentTag templateable

Allow the commentTag field to support Go template expressions, similar to how content, repoURLPath, and revisionPath already do. This would allow users to include dynamic values to avoid per-application collisions:

pullRequestComment:
  content: |
    Application {{.app.metadata.name}} sync status: {{.app.status.sync.status}}
  commentTag: "{{.app.metadata.name}}"

This would generate a unique hidden HTML tag per Application, e.g.:

<!-- argocd-notifications my-app -->

...preventing different Applications from overwriting each other's comments.

2. Add comment folding/minimization options

Introduce new optional fields on GitHubPullRequestComment inspired by marocchino/sticky-pull-request-comment, such as:

New field Type Description
hide bool Minimize the previous comment before creating a new one
hideAndRecreate bool Minimize old comment and post a new comment at the bottom
hideClassify string Reason for minimizing (e.g., OUTDATED, RESOLVED)

Example usage:

pullRequestComment:
  content: |
    App {{.app.metadata.name}} deployed to {{.app.spec.destination.namespace}}
  commentTag: "{{.app.metadata.name}}"
  hideAndRecreate: true
  hideClassify: "OUTDATED"

This requires using GitHub's GraphQL API minimizeComment mutation, as the REST API does not support minimizing comments.

Why This Matters

In monorepo or multi-app setups, multiple Argo CD Applications may target the same Git repository and therefore the same PR. Without a templateable commentTag or per-app differentiation, notifications from different Applications overwrite each other, making PR comments unreliable. Adding folding support also improves the signal-to-noise ratio on busy PRs by collapsing outdated statuses.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions