Files
portfolio/.github/workflows/minify.yml
2022-12-20 00:56:42 -05:00

35 lines
1021 B
YAML

# 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 i -g terser csso-cli html-minifier
# Use CLI tools to minify, overwriting existing files
- run: for i in `find . -name "*.js" -type f`; do terser $i --compress -o $i; done
- run: for i in `find . -name "*.css" -type f`; do csso $i -o $i; done
- run: for i in `find . -name "*.html" -type f`; do html-minifier --remove-comments --collapse-whitespace $i -o $i; done
# Push changes to `build` branch
- name: Create report file
run: date +%s > report.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
base: build
token: ${{ secrets.GITHUB_TOKEN }}