setup automatic minification
All checks were successful
Minify HTML and CSS / minify (push) Successful in 38s
All checks were successful
Minify HTML and CSS / minify (push) Successful in 38s
This commit is contained in:
parent
442620c4e4
commit
96d65a7ffe
46
.gitea/workflows/minify.yaml
Normal file
46
.gitea/workflows/minify.yaml
Normal file
@ -0,0 +1,46 @@
|
||||
name: Minify HTML and CSS
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
minify:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
|
||||
- name: Install minification tools
|
||||
run: |
|
||||
npm install -g html-minifier-terser csso-cli
|
||||
|
||||
- name: Minify HTML files
|
||||
run: |
|
||||
find src/ -name '*.html' -exec sh -c 'html-minifier-terser --collapse-whitespace --remove-comments --minify-js true --minify-css true -o "${0%.html}.min.html" "$0"' {} \;
|
||||
|
||||
- name: Minify CSS files
|
||||
run: |
|
||||
find src/css/ -name '*.css' -exec sh -c 'csso "$0" --output "${0%.css}.min.css"' {} \;
|
||||
|
||||
- name: Commit and push changes
|
||||
env:
|
||||
USERNAME_GITEA: ${{ secrets.USERNAME_GITEA }}
|
||||
TOKEN_GITEA: ${{ secrets.TOKEN_GITEA }}
|
||||
run: |
|
||||
git config --global user.name "LibreCloud Actions Bot"
|
||||
git config --global user.email "git@pontusmail.org"
|
||||
git remote set-url origin https://${USERNAME_GITEA}:${TOKEN_GITEA}@git.pontusmail.org/aidan/pontus.git
|
||||
git add .
|
||||
git commit -m "[bot] Minifying HTML and CSS automatically"
|
||||
git push origin main
|
Loading…
x
Reference in New Issue
Block a user