-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added workflow to automatically resize large gifs (#74)
- Loading branch information
1 parent
286cea4
commit 3f9d5bf
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
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 |