Calibre launched a new GitHub Action that allows you to compress raster images with minimal setup and automatically run on every pull request. Here is how it works:

The action uses the most efficient, lossless compression libraries—mozjpeg and libvips that work with PNGs and JPGs. What’s excellent about embedding a compression step directly in the developer platform (or CI) rather than in local development environments (or relying on drag-and-drop tools) is that no image can hit production uncompressed. This empowers any contributors with basic knowledge of GitHub to update images without introducing performance regression and saves everyone time.

You can find this action on Github’s Action marketplace and the source code is available too.