forked from DevExpress/DevExtreme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drone-cache.sh
executable file
·44 lines (35 loc) · 1.14 KB
/
drone-cache.sh
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
40
41
42
43
44
#!/bin/bash
MAIN_REPO="DevExpress/DevExtreme"
MAIN_BRANCH=$(node -e "console.log(require('./package.json').version.split(/\./g).slice(0, 2).join('_'))")
CACHE_DIRS="node_modules dotnet_packages"
CACHE_URL="http://devextreme-ci-cache.s3.amazonaws.com/$MAIN_BRANCH"
if [ "$1" == "rebuild" ]; then
if [ "$DRONE_BUILD_EVENT" != "push" ] || [ "$DRONE_REPO" != "$MAIN_REPO" ] || [ "$DRONE_BRANCH" != "$MAIN_BRANCH" ]; then
echo "Skip"
exit 0
fi
for i in $CACHE_DIRS; do
if [ -e $i ]; then
if tar cf - $i | lz4 | curl -Lsf -X PUT -H "x-amz-acl: bucket-owner-full-control" --data-binary @- "$CACHE_URL/$i.tar.lz4"; then
echo "Uploaded: $i"
else
echo "Failed to upload: $i"
fi
else
echo "Does not exist: $i"
fi
done
exit 0
fi
if [ "$1" == "restore" ]; then
for i in $CACHE_DIRS; do
if curl -Lsf "$CACHE_URL/$i.tar.lz4" | lz4 -d | tar xf - 2>/dev/null; then
echo "Restored: $i"
else
echo "Failed to restore: $i"
fi
done
exit 0
fi
echo "Not enough arguments"
exit 1