-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (33 loc) · 1.53 KB
/
minify.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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
run-name: Minify JS/CSS/HTML [gh-pages branch]
# Run on pushes to `main` branch
on:
push:
branches:
- 'main'
jobs:
checkout-minify-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Install NodeJS and CLI tools
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: npm install -g terser
- run: npm install -g csso-cli
- run: npm install -g html-minifier
# Perform minification, overwriting original files
- run: terser ./script.js --compress --mangle -o ./script.js
- run: terser ./sw.js --compress --mangle -o ./sw.js
- run: csso ./css/style.css -o ./css/style.css
- run: html-minifier --collapse-boolean-attributes --collapse-whitespace --minify-css --minify-js --minify-urls --remove-attribute-quotes --remove-comments --remove-empty-attributes --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-style-link-type-attributes --remove-tag-whitespace --use-short-doctype -o ./index.html ./index.html
# (Force) push changes to `gh-pages` branch
- run: |
git config user.name aricooperdavis
git config user.email [email protected]
git commit -am 'Automated minify of ${{ github.sha }}'
git push --force -u origin main:gh-pages