-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
process-static
executable file
·37 lines (28 loc) · 751 Bytes
/
process-static
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
32
33
34
35
36
37
#!/bin/bash
set -o errexit -o nounset -o pipefail
shopt -s dotglob extglob globstar
if [[ ${GITHUB_ACTIONS:-false} != true ]]; then
source venv/bin/activate
fi
if [[ $# -eq 1 ]]; then
fd=$1
else
touch lock
exec {fd}< lock
fi
if ! flock -n $fd; then
echo already processing/deploying static files >&2
exit 1
fi
rm -rf nginx-tmp
cp -a nginx nginx-tmp
gixy nginx-tmp/nginx.conf
rm -rf static-tmp
cp -a static static-tmp
for file in static-tmp/**/*.json; do
json_verify < "$file" >/dev/null
json_reformat -m < "$file" | sponge "$file"
done
find static-tmp -name '*.xml' -exec xmllint --noblanks {} --output {} \;
find static-tmp -regex '.+\.\(ico\|json\|svg\|txt\|xml\)' |
parallel -q ::: brotli zopfli :::: -