Post image generated by a GitHub action as a comment on the PR
Asked Answered
G

0

7

I have a GitHub action that generates a PHPUnit Code Coverage report and takes a screenshot of the report as a PNG. I would like to post this image as a comment on the PR. Initially, I tried to post the comment as a base64 encoded URL in the comment. However, it does not appear that GitHub supports rendering images in this way in PR comments. I then tried to upload the image as a build artifact, but GitHub provides me no way to link this asset as an image in the comment. I would like to avoid uploading build artifacts to a publically available location just to get the image to load in the comment with the normal image syntax.

When dragging and dropping a file into a comment GitHub appears to upload the image to a location scoped to the specific PR assets. Can I use this same process somehow to get the image to load in the PR comment?

As a temporary measure, I have set the image to upload as a build artifact and link the user to download this build artifact as a comment on the PR. However, I would like the image to be displayed directly in the PR comment instead.

Gish answered 9/9, 2023 at 1:49 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.