argoproj / argoproj/notifications-engine
feat(github): enhance pullRequestComment with folding support and templateable commentTag
- Dominant language
- Go
- Stars
- 334
- Forks
- 217
- PR merge metrics
- No merged PRs in 30d
Description
### 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`](https://github.com/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`](https://github.com/argoproj/notifications-engine/blob/master/pkg/services/github.go)).
- When a `commentTag` is provided, the engine searches for a comment containing `` 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:
```yaml
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.:
```
```
...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:
```yaml
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](https://docs.github.com/en/graphql/reference/mutations#minimizecomment), 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
- [`marocchino/sticky-pull-request-comment`](https://github.com/marocchino/sticky-pull-request-comment) — inspiration for `hide`, `hide_and_recreate`, `hide_classify` options
- GitHub GraphQL API: [`minimizeComment` mutation](https://docs.github.com/en/graphql/reference/mutations#minimizecomment)
- Current implementation: [`pkg/services/github.go`](https://github.com/argoproj/notifications-engine/blob/master/pkg/services/github.go)
- Current docs: [`docs/services/github.md`](https://github.com/argoproj/notifications-engine/blob/master/docs/services/github.md)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in pkg/services/github.go and compare the existing pullRequestComment behavior with docs/services/github.md. Review GitHub's GraphQL minimizeComment mutation, then define how templateable commentTag and the hide options should interact; done means unique per-application tags and the requested minimization behavior are documented and implemented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github, go, graphql
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100