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
|
- name: Build site
|
||||||
run: hexo generate
|
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
|
- name: Upload site artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -92,8 +92,9 @@ The [deploy workflow](.gitea/workflows/deploy.yml) runs four gated stages:
|
|||||||
1. **lint** — checks all Markdown in `source/` and `scaffolds/` with
|
1. **lint** — checks all Markdown in `source/` and `scaffolds/` with
|
||||||
`markdownlint-cli2` (house style codified in `.markdownlint-cli2.jsonc`)
|
`markdownlint-cli2` (house style codified in `.markdownlint-cli2.jsonc`)
|
||||||
2. **build** — checks out the repo, sets up Node 22, runs `yarn install
|
2. **build** — checks out the repo, sets up Node 22, runs `yarn install
|
||||||
--frozen-lockfile` and `hexo generate` (~171 files, ~9 MB into `public/`),
|
--frozen-lockfile` and `hexo generate`, optimizes every PNG/JPEG in the
|
||||||
then uploads the site as a workflow artifact
|
built output with pngquant/oxipng/jpegoptim (~58% smaller images, originals
|
||||||
|
in `source/` untouched), then uploads the site as a workflow artifact
|
||||||
3. **test** — validates the built artifact without touching production:
|
3. **test** — validates the built artifact without touching production:
|
||||||
structural checks (index, theme assets, file count) plus a serving smoke
|
structural checks (index, theme assets, file count) plus a serving smoke
|
||||||
test that requests the homepage, a real post page, and the stylesheet
|
test that requests the homepage, a real post page, and the stylesheet
|
||||||
|
|||||||
Reference in new issue
Block a user