Skip to content

Merge pull request #140 from DarSitam/deposit #105

Merge pull request #140 from DarSitam/deposit

Merge pull request #140 from DarSitam/deposit #105

Workflow file for this run

name: Optimize Images
on:
push:
branches:
- main
paths:
- '.github/workflows/imgopt.yml'
- 'hud-resources/**.jpg'
- 'hud-resources/**.jpeg'
- 'hud-resources/**.png'
- 'hud-resources/**.webp'
concurrency:
group: ${{ github.repository }}
cancel-in-progress: true
jobs:
imgopt:
name: Optimize Images
runs-on: ubuntu-latest
if: github.repository == 'mastercomfig/hud-db'
steps:
- uses: actions/checkout@v3
- name: Convert to WebP
id: convert
run: |
sudo apt-get -y install webp
pip install webp-converter
cd hud-resources
WEBP_OUTPUT="$(webpc -q=75 --r)"
echo "$WEBP_OUTPUT" | grep -q "NOT convert" | ( ! grep -q "Converted files count: 0" )
echo "$WEBP_OUTPUT"
- name: Compress Images
id: compress
uses: calibreapp/image-actions@main
with:
# The `GITHUB_TOKEN` is automatically generated by GitHub and scoped only to the repository that is currently running the action. By default, the action can’t update Pull Requests initiated from forked repositories.
# See https://docs.github.com/en/actions/reference/authentication-in-a-workflow and https://help.github.com/en/articles/virtual-environments-for-github-actions#token-permissions
githubToken: ${{ secrets.GITHUB_TOKEN }}
compressOnly: true
webpQuality: '90'
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Create New Pull Request If Needed
if: steps.compress.outputs.markdown != '' || steps.convert.outcome == 'success'
uses: peter-evans/create-pull-request@v4
with:
title: Auto Optimize Images
branch: imgopt
branch-suffix: short-commit-hash
commit-message: optimize images for ${{ steps.vars.outputs.sha_short }}
body: ${{ steps.compress.outputs.markdown || 'Converted images to WebP.' }}