-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (43 loc) · 1.24 KB
/
Copy pathoptimize-images.yml
File metadata and controls
52 lines (43 loc) · 1.24 KB
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
50
51
52
name: Optimize Images
on:
pull_request:
paths:
- '**.png'
- '**.jpg'
- '**.jpeg'
- 'docs/assets/**'
jobs:
optimize:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install optimization tools
run: |
sudo apt-get update
sudo apt-get install -y pngquant optipng jpegoptim webp
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Python dependencies
run: |
pip install pillow
- name: Optimize images
run: |
python scripts/optimize_images.py
- name: Check if images were optimized
id: check_changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Commit optimized images
if: steps.check_changes.outputs.changes == 'true'
uses: EndBug/add-and-commit@v9
with:
message: 'Optimize images [skip ci]'
add: '*.png *.jpg *.jpeg *.webp'
committer_name: 'GitHub Actions'
committer_email: 'actions@github.com'