Skip to content

Add CI workflow to optimize PNG images with oxipng#1936

Open
cderv wants to merge 2 commits intomainfrom
worktree-optimize-images-ci
Open

Add CI workflow to optimize PNG images with oxipng#1936
cderv wants to merge 2 commits intomainfrom
worktree-optimize-images-ci

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented Mar 4, 2026

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 main or prerelease.

How it works

On push to main/prerelease with **/*.png changes:

  1. Downloads a prebuilt oxipng binary from GitHub releases
  2. Detects which PNG files changed in the push
  3. Runs oxipng -o 4 -i 0 --strip safe (lossless compression, remove interlacing, strip safe metadata)
  4. Commits optimized images back via stefanzweifel/git-auto-commit-action

Runs post-merge rather than on PRs, so it works for fork contributions too. The existing port-to-prerelease workflow handles syncing to prerelease, where this workflow runs independently.

No infinite loop risk: commits via GITHUB_TOKEN don'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-files to a commit SHA in both this workflow and preview.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.

cderv added 2 commits March 4, 2026 20:28
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.
@github-actions github-actions bot temporarily deployed to pull request March 4, 2026 19:40 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

📝 Preview Deployment

🔍 Full site preview: https://deploy-preview-1936.quarto.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant