PROD: Created minify workflow.
This commit is contained in:
33
.github/workflows/minify.yml
vendored
Normal file
33
.github/workflows/minify.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# A Github Action that minifies html/css/js and pushes it to a new branch
|
||||
name: minify
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
|
||||
jobs:
|
||||
minify:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
# Install 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
|
||||
|
||||
# Use CLI tools to minify, overwriting existing files
|
||||
- run: for i in ./js/*.js; do terser $i --compress -o $i; done
|
||||
- run: for i in ./css/*.css; do csso $i -o $i; done
|
||||
- run: for i in ./html/*.html; do html-minifier [--your-options-here] $i -o $i; done
|
||||
|
||||
# Push changes to `build` branch
|
||||
- run: |
|
||||
git config user.name MajorDroolz
|
||||
git config user.email MajorDroolz@user.noreply.github.com
|
||||
git commit -am 'Automated minify of ${{ github.sha }}'
|
||||
git push --force -u origin main:build
|
||||
Reference in New Issue
Block a user