47 lines
1.4 KiB
YAML
47 lines
1.4 KiB
YAML
|
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' ! -name '*min*' -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' ! -name '*min*' -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
|