mercari / tfnotify

A CLI command to parse Terraform execution result and notify it to GitHub
MIT License
619 stars 91 forks source link

New comment every time or updates to existing comments? #85

Open jamesh37 opened 3 years ago

jamesh37 commented 3 years ago

I am running 3 TF plans in a given PR workflow, and tfnotify is correctly giving me a new comment for each plan. However I get a set of 3 new comments every time the workflow runs. Is this expected behaviour or should it update/replace the comments on each run?

quulah commented 2 years ago

Currently using tfcmt which does create a new comment for each workflow, but was thinking of changing to tfnotify (for other reasons). In any case, I would like to have this supported as well.

The GitHub API has an option to either update or create a new comment.

For the update, you may need to ear mark each comment so you can track them in some way. Find the correct comment ID and then update the relevant one.

I've personally used some "comment created by something" text in the comments, and then list all the comments, find the text, and grab the ID of that.

https://docs.github.com/en/rest/reference/issues#list-issue-comments https://docs.github.com/en/rest/reference/issues#update-an-issue-comment