Skip to content

Commit

Permalink
Add minification of json files
Browse files Browse the repository at this point in the history
  • Loading branch information
ukriu authored Aug 19, 2024
1 parent 0def046 commit 712b167
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/minify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: npm install -g pnpm

- name: Install minification tools locally
run: pnpm add -D html-minifier-terser clean-css-cli terser
run: pnpm add -D html-minifier-terser clean-css-cli terser json-minify

- name: Fetch all branches
run: git fetch --all
Expand All @@ -31,11 +31,12 @@ jobs:
run: |
git checkout -B minified origin/main
- name: Minify HTML, CSS, and JS
- name: Minify HTML, CSS, JS, and JSON
run: |
find . -name "*.html" -exec npx html-minifier-terser --collapse-whitespace --remove-comments --minify-js true --minify-css true -o {} {} \;
find . -name "*.css" -exec npx cleancss -o {} {} \;
find . -name "*.js" -exec npx terser --compress --mangle --output {} -- {} \;
find . -name "*.json" -exec sh -c 'npx json-minify < "$1" > "$1.tmp" && mv "$1.tmp" "$1"' _ {} \;
- name: Commit and Push Minified Files to Minified Branch
env:
Expand All @@ -44,5 +45,5 @@ jobs:
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git add -A
git commit -m "Minified HTML, CSS, and JS"
git commit -m "Minified HTML, CSS, JS, and JSON"
git push --force "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/ukrioo/ukrioo.github.io.git" minified

0 comments on commit 712b167

Please sign in to comment.