update resume #2
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
name: Minify CSS and JS | |
on: | |
push: | |
branches: | |
- master # Replace with your branch name | |
jobs: | |
minify: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16' # Or your preferred version | |
- name: Install Minification Tools | |
run: | | |
npm install terser -g | |
npm install clean-css-cli -g | |
- name: Minify JavaScript | |
run: | | |
for file in js/*.js; do | |
if [[ "$file" != *.min.js ]]; then | |
terser "$file" -o "js/$(basename "$file" .js).min.js" -c -m | |
fi | |
done | |
- name: Minify CSS | |
run: | | |
for file in css/*.css; do | |
if [[ "$file" != *.min.css ]]; then | |
cleancss -o "css/$(basename "$file" .css).min.css" "$file" | |
fi | |
done | |
- name: Commit and push all minified files | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add js/*.min.js css/*.min.css || true | |
if git diff-index --quiet HEAD --; then | |
echo "No changes to commit" | |
else | |
git commit -m "Auto-minify JavaScript and CSS files" | |
git push | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |