Image Optimization #6
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: Image Optimization | |
on: | |
workflow_dispatch: | |
inputs: | |
target-branch: | |
description: 'Target Branch for Commit' | |
required: true | |
default: 'developer' | |
jobs: | |
optimize-images: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 14 | |
- name: Install ImageMagick | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y imagemagick | |
- name: Install jpegoptim | |
run: sudo apt-get install -y jpegoptim | |
- name: Install SVGO | |
run: npm install -g svgo | |
- name: Optimize Images | |
run: | | |
find . -type f \( -name "*.png" -o -name "*.jpg" -o -name "*.jpeg" -o -name "*.svg" \) -exec mogrify -resize 50% {} \; | |
find . -type f -name "*.jpg" -exec jpegoptim {} \; | |
find . -type f -name "*.svg" -exec svgo {} \; | |
- name: Add Changes | |
run: git add . | |
- name: Commit Changes | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "Image Optimization" | |
git commit -m "Optimize images" | |
git push https://[email protected]/${{ github.repository }} ${{ github.event.inputs.target-branch }} |