Update .gitea/workflows/compressimage.yml
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
name: Enforce Image Standards
|
name: Enforce Image Standards
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- beta
|
- beta
|
||||||
@@ -8,7 +9,6 @@ on:
|
|||||||
- client
|
- client
|
||||||
- staging
|
- staging
|
||||||
- production
|
- production
|
||||||
pull_request:
|
|
||||||
paths:
|
paths:
|
||||||
- '**.jpg'
|
- '**.jpg'
|
||||||
- '**.jpeg'
|
- '**.jpeg'
|
||||||
@@ -28,25 +28,21 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y imagemagick jpegoptim pngquant
|
sudo apt-get install -y imagemagick jpegoptim pngquant
|
||||||
|
|
||||||
# Resize images larger than 1920px (keeps aspect ratio)
|
|
||||||
- name: Resize Oversized Images
|
- name: Resize Oversized Images
|
||||||
run: |
|
run: |
|
||||||
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) \
|
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) \
|
||||||
-exec mogrify -resize 1920x1920\> {} \;
|
-exec mogrify -resize 1920x1920\> {} \;
|
||||||
|
|
||||||
# Optimize JPEG safely
|
|
||||||
- name: Optimize JPEG
|
- name: Optimize JPEG
|
||||||
run: |
|
run: |
|
||||||
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) \
|
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) \
|
||||||
-exec jpegoptim --strip-all --max=85 {} \;
|
-exec jpegoptim --strip-all --max=85 {} \;
|
||||||
|
|
||||||
# Optimize PNG safely
|
|
||||||
- name: Optimize PNG
|
- name: Optimize PNG
|
||||||
run: |
|
run: |
|
||||||
find . -type f -iname "*.png" \
|
find . -type f -iname "*.png" \
|
||||||
-exec pngquant --force --ext .png --quality=75-90 {} \;
|
-exec pngquant --force --ext .png --quality=75-90 {} \;
|
||||||
|
|
||||||
# Commit only if changes exist
|
|
||||||
- name: Commit Optimized Images
|
- name: Commit Optimized Images
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name "gitea-actions"
|
git config --global user.name "gitea-actions"
|
||||||
@@ -55,5 +51,7 @@ jobs:
|
|||||||
if [ -n "$(git status --porcelain)" ]; then
|
if [ -n "$(git status --porcelain)" ]; then
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Auto resize and optimize images"
|
git commit -m "Auto resize and optimize images"
|
||||||
git push origin HEAD:${{ github.head_ref }}
|
git push origin HEAD:${{ gitea.head_ref }}
|
||||||
fi
|
else
|
||||||
|
echo "No changes to commit"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user