Skip to content

Commit

Permalink
Added workflow to automatically resize large gifs (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
SijmenHuizenga authored Oct 6, 2020
1 parent 286cea4 commit 3f9d5bf
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/resize-gifs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Resize gifs

on:
pull_request:
paths:
- 'public/images/*.gif'

jobs:
resize-images:
name: resize image
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
# Ref needed to work on forked repo
ref: ${{ github.event.pull_request.head.ref }}
- name: Resize large images to 300px width
run: |
for filename in public/images/*.gif; do
width=$( identify -ping -format '%w ' $filename | cut -d " " -f 1)
if (( $width > 300 )); then
echo "GIF $filename has width $width. Resizing to 300px width"
mogrify -resize 300 $filename
else
echo "GIF $filename has width $width. Not resizing."
fi
done
- name: Add & Commit files
run: |
# only commit if files were changed
if [[ $(git diff --stat) != '' ]]; then
git config --local user.email [email protected]
git config --local user.name github-actions
git add .
git commit -m "Resize large images to 300px" -a
git push
fi

0 comments on commit 3f9d5bf

Please sign in to comment.