Update Blog post “plan-your-spice-garden/index” #411
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Compress Images on Push to Main with Commit | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'content/uploads/**.jpg' | |
- 'content/uploads/**.jpeg' | |
- 'content/uploads/**.png' | |
- 'content/uploads/**.webp' | |
- 'content/posts/**/**.jpg' | |
- 'content/posts/**/**.jpeg' | |
- 'content/posts/**/**.png' | |
- 'content/posts/**/**.webp' | |
jobs: | |
build: | |
name: optimize-images | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@main | |
- name: Resize Images | |
id: resize-images | |
uses: gonzalonaveira/gh-image-resizing@master | |
with: | |
IMAGES_MAX_WIDTH: "1080" | |
IMAGES_QUALITY: "80" | |
IMAGES_FORMATS: "jpg, jpeg, png, webp" | |
IMAGES_DIRECTORIES: "content/uploads,content/posts" | |
- name: Commit changes direct to main | |
run: | | |
if [[ -n "$(git status --porcelain)" ]]; then | |
echo "Committing compressed images" | |
git config --global user.email "[email protected]" | |
git config --global user.name "Peter" | |
git stash clear | |
git stash | |
git pull | |
git stash pop | |
git diff-index --quiet HEAD || git commit -am "Compressing images" | |
git push | |
else | |
echo "There are no changes to commit"; | |
fi | |