Open Zingzy opened 19 hours ago
name: Minify and Deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install dependencies
run: npm install html-minifier cssnano uglify-js
- name: Minify HTML
run: |
find . -name "*.html" -exec html-minifier --collapse-whitespace --remove-comments --minify-css true --minify-js true -o {} {} \;
- name: Minify CSS
run: |
find . -name "*.css" -exec cssnano {} {} \;
- name: Minify JS
run: |
find . -name "*.js" -exec uglifyjs --compress --mangle -o {} -- {} \;
- name: Commit and push changes
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git checkout -b deployment
git add .
git commit -m "Minify HTML, CSS, and JS files"
git push --force --set-upstream origin deployment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Possible Workflow (Untested)
Description
Implement a GitHub Actions workflow to automatically minify HTML, CSS, and JavaScript files and push the optimized code to a deployment branch. This will improve the performance of the web application by reducing the size of the files that need to be downloaded by the user's browser.
Tasks
[ ] Set Up Node.js Environment
[ ] Install Minification Tools
html-minifier
,cssnano
,uglify-js
).[ ] Minify HTML Files
html-minifier
to minify HTML files.[ ] Minify CSS Files
cssnano
to minify CSS files.[ ] Minify JS Files
uglify-js
to minify JavaScript files.[ ] Commit and Push Changes
deployment
.deployment
branch on GitHub.[ ] Testing