swap for optipng

This commit is contained in:
boubou19 2025-07-23 19:58:40 +02:00
parent dbf92f682a
commit 480322a45e

View File

@ -9,26 +9,26 @@ jobs:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
steps: steps:
- name: Checkout Repo - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Compress Images - name: Install optipng
id: compress-images run: sudo apt-get update && sudo apt-get install -y optipng
uses: stellasoftio/image-optimizer-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
compress-png: true
compress-svg: false
compress-jpg: false
compress-webp: false
compress-avif: false
- name: Fail if image optimization was needed - name: Optimize PNG files
if: steps.compress-images.outputs.markdown_report != ''
run: | run: |
echo "Unoptimized image(s) have been detected." find . -type f -name "*.png" ! -path "./.git/*" -exec optipng -o7 {} +
exit 1
- name: Check for changes
id: git-diff
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "Everything is already correctly compressed."
exit 0
else
echo "Some files aren't correctly compressed."
exit 1
fi
- name: Create Pull Request if Needed - name: Create Pull Request if Needed
if: steps.compress-images.outputs.markdown_report != '' if: steps.compress-images.outputs.markdown_report != ''
@ -43,7 +43,7 @@ jobs:
--head "${FIXED_BRANCH}" \ --head "${FIXED_BRANCH}" \
--base "${PR_BRANCH}" \ --base "${PR_BRANCH}" \
--title "Optimising images contained in ${PR_BRANCH} for #${{ github.event.pull_request.number }}" \ --title "Optimising images contained in ${PR_BRANCH} for #${{ github.event.pull_request.number }}" \
--body "Automatic image compression, applies to PR #${{ github.event.pull_request.number }}\n\n${{ steps.compress-images.outputs.markdown_report }}" \ --body "Automatic image compression, applies to PR #${{ github.event.pull_request.number }}" \
2>&1 | tee pr-message.log || true 2>&1 | tee pr-message.log || true
gh pr comment "${PR_BRANCH}" -F pr-message.log || true gh pr comment "${PR_BRANCH}" -F pr-message.log || true
shell: shell: