-
-
Notifications
You must be signed in to change notification settings - Fork 151
/
upload-examples
executable file
·39 lines (36 loc) · 1.26 KB
/
upload-examples
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
38
39
#!/bin/sh
readonly target="s3://demo.thi.ng/umbrella"
readonly opts="--profile toxi-s3 --acl public-read"
if [ $# == 1 ]; then
modules="examples/$1"
else
modules="examples/*"
fi
for m in $modules; do
if [ -d "$m" ] && [ ! -e "$m/.skip" ]; then
name=$(echo $m | cut -d '/' -f 2)
dest="$target/$name"
src=$(ls $m/out/*.js.gz | cut -d '/' -f 4)
echo "------------------------------"
echo "uploading $m..."
echo "------------------------------"
assets=$(find $m/out/ -name '*.png')
if [ ! -z $assets ]; then
aws s3 cp $m/out/*.png $dest/ $opts
fi
assets=$(find $m/out/ -name '*.json')
if [ ! -z $assets ]; then
for a in $assets; do
origname=$(basename -- "$a")
gzip $a
aws s3 cp $a.gz $dest/$origname $opts --content-type "application/json; charset=utf-8" --content-encoding gzip
done
fi
for js in $src; do
len=${#js}
js2="${js:0:len-3}"
aws s3 cp $m/out/$js $dest/$js2 $opts --content-type "application/javascript; charset=utf-8" --content-encoding gzip
done
aws s3 cp $m/out/index.html $dest/ $opts --cache-control "max-age=900"
fi
done