-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (39 loc) · 1.27 KB
/
ImageOptimization.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 }}