mirror of
https://github.com/GTNewHorizons/GTNH-Actions-Workflows.git
synced 2025-08-29 06:40:10 +02:00
swap for optipng
This commit is contained in:
parent
dbf92f682a
commit
480322a45e
38
.github/workflows/optimize-images.yml
vendored
38
.github/workflows/optimize-images.yml
vendored
@ -9,27 +9,27 @@ 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
|
|
||||||
if: steps.compress-images.outputs.markdown_report != ''
|
|
||||||
run: |
|
|
||||||
echo "Unoptimized image(s) have been detected."
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
|
|
||||||
|
- name: Optimize PNG files
|
||||||
|
run: |
|
||||||
|
find . -type f -name "*.png" ! -path "./.git/*" -exec optipng -o7 {} +
|
||||||
|
|
||||||
|
- 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 != ''
|
||||||
if: ${{ failure() && github.event_name == 'pull_request' && !github.event.pull_request.draft }}
|
if: ${{ failure() && github.event_name == 'pull_request' && !github.event.pull_request.draft }}
|
||||||
@ -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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user