calibreapp / image-actions

A Github Action that automatically compresses JPEGs, PNGs and WebPs in Pull Requests.
https://calibreapp.com/blog/compress-images-in-prs
GNU General Public License v3.0
1.42k stars 67 forks source link

[Feature Request] Simple markdown template #107

Open lfgcampos opened 2 years ago

lfgcampos commented 2 years ago

What problem would this feature solve?

Currently, the only output we can get from the action is the steps.calibre.outputs.markdown which uses either the pr-comment.md or the inline-pr-comment-with-diff.md. In certain cases, this template is too big to be used as an environment variables on the Actions runner causing an Error: Argument list too long error.

Describe the solution you’d like to see

I would like to see something like a pr-comment-minimal.md where you only show the comments and numbers without the big table with all the images and changes that happened. eg:

Images automagically compressed by Calibre's image-actions ✨

Compression reduced images by <%- overallPercentageSaved %>%, saving <%- overallBytesSaved %>.

<% if(unoptimisedImages.length) { -%> <%- unoptimisedImages.length %> <%- unoptimisedImages.length > 1 ? 'images' : 'image' %> did not require optimisation. <% } %>

Describe alternatives you’ve considered

Alternative is to not use the output of this action on follow up actions (like the create-pull-request one).

Additional context

N/A

benschwarz commented 2 years ago

@lfgcampos Thanks for logging this. This isn't something I've personally encountered, but I can see how some changes would improve things.

We could add a simple markdown template as you've suggested, but I think I'd prefer to limit the output of the existing templates so that up to 50 images are posted to a markdown table. If there's more images than 50, the table could be omitted.

Perhaps the output could be along the lines of:

Images automagically compressed by Calibre's image-actions ✨

Compression reduced images by <%- overallPercentageSaved %>%, saving <%- overallBytesSaved %>.

<% if(optimisedImages.length < 50) { -%> <!-- table of compression summary, limited to 50 images --><% } %>

<% if(unoptimisedImages.length) { -%> <%- unoptimisedImages.length %> <%- unoptimisedImages.length > 1 ? 'images' : 'image' %> did not require optimisation. <% } %>

What do you think @lfgcampos? Would that cover your use case?

Would you be in a position to help action this change?

lfgcampos commented 2 years ago

Thanks for the quick reply @benschwarz! Sounds good to me!

Another small thing I would add would be the number of optimized images in case the table is not shown. At least we would know how many were optimized and how many wasn't.

Sure, I can try to work on this change as it looks trivial!

lfgcampos commented 2 years ago

PR is opened!

lfgcampos commented 2 years ago

Hi @benschwarz, sorry to bother you but any chance to look at the PR?