Add build-time image optimization (pngquant/oxipng/jpegoptim) to pipeline
This commit is contained in:
1 parent
3f5ba20810
commit
663c0aab25
2 files changed
+12
-2
No files matched your search
@@ -48,6 +48,15 @@ jobs:
|
||||
- name: Build site
|
||||
run: hexo generate
|
||||
|
||||
# Best-effort image optimization at build time: originals in source/
|
||||
# stay untouched, only the built artifact shrinks (~58% on this site).
|
||||
- name: Optimize images
|
||||
run: |
|
||||
apt-get update -qq && apt-get install -y -qq pngquant oxipng jpegoptim
|
||||
find public -type f -name '*.png' -exec sh -c 'pngquant --quality=80-95 --strip --force --skip-if-larger --output "$1" "$1"; oxipng -o max -q "$1"' _ {} \;
|
||||
find public -type f \( -name '*.jpg' -o -name '*.jpeg' \) -exec jpegoptim --max=90 --strip-all --threshold=5 -q {} \;
|
||||
echo "site size after optimization: $(du -sh public | cut -f1)"
|
||||
|
||||
- name: Upload site artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
|
||||
Reference in new issue
Block a user