Files
Wdipl-react/.gitea/workflows/compressimage.yml
Rajendra Reddy 8e3839397c
Some checks failed
Deployment / deploy (push) Failing after 12s
Upload files to ".gitea/workflows"
2026-04-16 08:17:25 +00:00

67 lines
1.6 KiB
YAML

name: Enforce Image Standards
on:
pull_request:
branches:
- main
- beta
- testing
- client
- staging
- production
types: [opened, synchronize, reopened]
paths:
- '**/*.jpg'
- '**/*.jpeg'
- '**/*.png'
workflow_dispatch:
jobs:
optimize:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ gitea.head_ref }} # IMPORTANT
- name: Install Image Tools
run: |
sudo apt-get update
sudo apt-get install -y imagemagick jpegoptim pngquant
- name: Resize Oversized Images
run: |
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) \
-exec mogrify -resize 1920x1920\> {} \;
- name: Optimize JPEG
run: |
find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) \
-exec jpegoptim --strip-all --max=85 {} \;
- name: Optimize PNG
run: |
find . -type f -iname "*.png" \
-exec pngquant --force --ext .png --quality=75-90 {} \;
# Commit changes if any
- name: Commit changes
run: |
git config --global user.name "CI Bot"
git config --global user.email "ci@local"
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "chore: optimize images via CI"
else
echo "No changes to commit"
fi
# Push back to PR branch
- name: Push changes
if: success()
run: |
git push origin HEAD:${{ gitea.head_ref }}