Added mobile support (partial) #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow is triggered by a push to the `main` branch | |
# which it checks out, minimises the appropriate html/css/js | |
# in-place, and pushes the changes to the `gh-pages` branch | |
name: Minify | |
on: | |
push: | |
branches: | |
- "main" | |
permissions: | |
contents: write | |
jobs: | |
checkout-minify-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Set up Minification Tools | |
run: | | |
npm install -g terser csso-cli html-minifier-terser | |
- name: Minify HTML, CSS, and JS | |
run: | | |
# Minify HTML files | |
find . -name "*.html" -exec html-minifier-terser --collapse-whitespace --remove-comments --minify-js true --minify-css true --output {}.min {} \; | |
find . -name "*.html.min" -exec bash -c 'mv "$0" "${0%.min}"' {} \; | |
# Minify CSS files | |
find . -name "*.css" -exec csso --output {} {} \; | |
# Minify JavaScript files | |
find . -name "*.js" -exec terser --compress --mangle --output {} -- {} \; | |
- name: Deploy to gh-pages | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git checkout --orphan gh-pages | |
git reset | |
git add -f . | |
git commit -m "Deploy minified files to gh-pages" | |
git push -f origin gh-pages | |
- name: Return to main | |
run: git checkout main |