-
Notifications
You must be signed in to change notification settings - Fork 6
/
run_optipng
executable file
·31 lines (24 loc) · 1.04 KB
/
run_optipng
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
readonly REPO_URL="https://${BOT_AUTH_TOKEN}@github.com/triplea-game/assets.git"
sudo apt install optipng
git checkout master
git config --global user.email "[email protected]"
git config --global user.name "tripleabuilderbot"
## find all PNG files, run lossless compression
## Filter output for errors, the line stating which file is being proccessed and percentage decrease
find . -name "*.png" \
| xargs optipng -preserve -o7 2>&1 \
| grep -iE "^** Processing|% decrease|error|warn"
## Toggle flag to fail on non-zero exit code.
## This will cause Travis to discontinue the build if we terminate with non-zero.
set -e
## If any files are changed, we'll commit them here
## If we commit and push, that will trigger a new build.
## If we trigger a new build, terminate the current build so we avoid deploying artifacts
git commit . -m "Apply optipng compression on all png files" && \
(
git push --quiet "$REPO_URL" master
echo "Committed compressed files. Terminating current build to abort deployment"
exit 1
)
exit 0