Anirban166 / Autocomment-atime-results

GitHub Action that automatically comments a plot and other atime-based results on PRs
https://github.com/marketplace/actions/autocomment-atime-results
0 stars 1 forks source link

My approach to comment a generated plot/image in a PR #5

Closed Anirban166 closed 8 months ago

Anirban166 commented 8 months ago

I discarded the idea of having a link to the zipped artifact as a comment for a pull request.

While it does work (using a combination of upload-artifact and one among the two options I got to work for commenting text in PR threads), it's a very indirect approach, requires the user to download the artifact, and for me to maintain a repository for archiving those artifacts keeping in mind the long-term retention and accessibility to them.

In response, I tried to have the image directly shown in the comment. The first approach I tried was to convert the image data (bytes) to base64 and then enclose it in a call to the GitHub API using github-script (to include it as a new comment under the GitHub-Actions bot), but the decoding wasn't proper:

image

The second approach was to use actions-comment-pull-request with a direct specification of the plot file (as opposed to a folder) but it led to failed image uploads:

image
Anirban166 commented 8 months ago

The final approach I used was to go with something that I explored nearly three years ago: https://github.com/Anirban166/dlcompare-bug/commit/34144c360aacaab1c2d0ebf1f4cdf420caf86453#comments

As I gathered, Iterative's CML workflows provide convenient containers (with common technologies and system dependencies configured) and their GitHub Actions pipeline allows for one to publish content in PRs without much hassle (which is perfect for my use case!).

Got it to work after some tinkering - Example Plot.