🤖 Learning GitHub Actions: Creating Beautiful PR Comments

shcheklein

Ivan Shcheklein

Posted on August 11, 2020

🤖 Learning GitHub Actions: Creating Beautiful PR Comments

You've probably seen the services that automatically generate GitHub PR comments with tables, images, links? Something like these two:

Codecov and Calibre reports

Magic, right ✨? Let's see how it can be done. We won't even need to use command line or offline editors this time!. This post covers:

  • How to create a "Hello world!" GitHub action online
  • Use CML scripts to generate comments with a custom Markdown that includes a picture 🖼.

Read more about CML. Besides GitHub comments, it can do the same for GitLab. Also, it's important that it was built with Machine Learning workflow in mind and automates a lot of tedious tasks in ML. besides simple reports.


Step 1: Create Action File

You can do this using GitHub online UI! Add the file .github/workflows/cml.yaml to your repo like this:

Btw, I've forked the DVC example get started repo to play with actions in this tutorial - feel free to do the same 😊

Create GitHub Action


Step 2: Add "Hello world!" Action

Feel free to copy-paste it from this gist:

Hello World Action


Step 3: Add Images 🖼️

That's where the the magic ✨ happens! Let's update a few lines of code like this (copy-paste from this gist):

Magic

cml-publish prc.svg --md >> report.md
cml-send-comment report.md

That's pretty all you need if you use the CML docker to run the action!

We specifically don't focus on the other three lines of the action, those that generate the image. It's out of scope of this post and it's specific to the repository. We definitely recommend reading it and DVC docs if you are machine learning practitioner.

cml-publish - saves an image and creates an ![Image](link) entry in the Markdown file report.md

cml-send-comment - sends the comment to GitHub to get the result 👇

Step 4: Profit 💥

Profit

The result looks like this:

Result

In this case it includes a precision-recall curve which is a fundamental and useful characteristic for a binary classifier. But you can include any images, any text using Markdown markup to create your own unique and useful report!


That's it for today 👌

We've just barely scratched the surface of the GitHub actions and CML capabilities! We definitely recommend taking a look at the actions marketplace.

And of course, read more about CML. Besides GitHub comments, it can do the same for GitLab. It was built with Machine Learning workflow in mind and automates a lot of tedious tasks in ML - like running training remotely.

💖 💪 🙅 🚩
shcheklein
Ivan Shcheklein

Posted on August 11, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related