Add CI workflow to optimize PNG images with oxipng#1936
Open
Conversation
Runs on push to main/prerelease when PNG files change. Optimizes images with oxipng and commits them back.
SHA-pinning prevents supply chain attacks on actions with write permissions. v46 to v47 is dependency bumps only.
Contributor
📝 Preview Deployment🔍 Full site preview: https://deploy-preview-1936.quarto.org |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An idea I wanted to do for a long time to reduce size of this repo, and especially images.
PNG images added to the repo are not optimized, leading to unnecessarily large files. This adds a GitHub Actions workflow that automatically optimizes PNG images using oxipng whenever they land on
mainorprerelease.How it works
On push to
main/prereleasewith**/*.pngchanges:oxipng -o 4 -i 0 --strip safe(lossless compression, remove interlacing, strip safe metadata)stefanzweifel/git-auto-commit-actionRuns post-merge rather than on PRs, so it works for fork contributions too. The existing
port-to-prereleaseworkflow handles syncing to prerelease, where this workflow runs independently.No infinite loop risk: commits via
GITHUB_TOKENdon't re-trigger workflows. As a secondary safeguard, oxipng is deterministic — re-optimizing an already-optimized image produces no diff.Also pins
tj-actions/changed-filesto a commit SHA in both this workflow andpreview.yml, and upgrades it from v46.0.5 to v47.0.5 (dependency bumps only). SHA-pinning mitigates supply chain risk for actions with write permissions.