forked from AKVorrat/STI-UI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_and_deploy.sh
executable file
·49 lines (39 loc) · 1.04 KB
/
build_and_deploy.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
45
46
47
48
49
#!/usr/bin/env sh
set -e
SITE_ENV="$1"
USER_AT_REMOTE_DIRECTORY="$2"
if [ -z "$USER_AT_REMOTE_DIRECTORY" ] && [ "$SITE_ENV" != "local" ] && [ "$SITE_ENV" != "production" ] && [ "$SITE_ENV" != "staging" ]
then
echo "./build_and_deploy.sh [production|staging|local] [user@hostname:/example_directory]"
exit 1
fi
log() {
echo ""
echo "# $1"
echo "================================================================================"
}
build() {
log "building client side assets..."
./node_modules/gulp/bin/gulp.js build
log "building markup..."
./build_html.rb
log "copying count.json..."
cp scripts/count.json build/site/scripts/count.json
}
deploy() {
# deploy but exclude deletion of counter
log "deploying... ($USER_AT_REMOTE_DIRECTORY)"
rsync -av build/site/ "$USER_AT_REMOTE_DIRECTORY" --force --delete --exclude=counter
}
clean() {
log "cleaning... (deleting ./public)"
rm -rf build/
}
# just build locally (./public)
if [ "$SITE_ENV" = "local" ]
then
build
exit 0
fi
# default build and deploy
build && deploy && clean