forked from simpleanalytics/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·48 lines (37 loc) · 1.65 KB
/
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
#!/bin/bash
set -u
set -e
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
scripts_path='./dist/latest/custom'
remote_path='[email protected]:/var/www/default'
if ! [[ $PWD = */scripts ]] || ! [[ -f "./dist/latest/custom/latest.js" ]]; then
echo -e "==> ${RED}Not in scripts directory, killing script${RESET}"
exit 1
fi
echo '==> You are about to deploy to production'
read -p "==> Are you sure? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo '==> Minifying one more time'
npm run minify
if [[ `git status --porcelain` ]]; then
echo -e "==> ${RED}There are changes in your repo, commit and test them first${RESET}"
exit 1
fi
echo '==> Deploying to production'
rsync --rsync-path="sudo rsync" "$scripts_path/e.js" "$remote_path/events.js"
rsync --rsync-path="sudo rsync" "$scripts_path/e.js.map" "$remote_path/events.js.map"
rsync --rsync-path="sudo rsync" "$scripts_path/latest.js" "$remote_path/latest.js"
rsync --rsync-path="sudo rsync" "$scripts_path/latest.js.map" "$remote_path/latest.js.map"
rsync --rsync-path="sudo rsync" "$scripts_path/light.js" "$remote_path/light.js"
rsync --rsync-path="sudo rsync" "$scripts_path/light.js.map" "$remote_path/light.js.map"
rsync --rsync-path="sudo rsync" "$scripts_path/proxy.js" "$remote_path/proxy.js"
rsync --rsync-path="sudo rsync" "$scripts_path/proxy.js.map" "$remote_path/proxy.js.map"
rsync --rsync-path="sudo rsync" "$scripts_path/../embed.js" "$remote_path/embed.js"
rsync --rsync-path="sudo rsync" "$scripts_path/../embed.js.map" "$remote_path/embed.js.map"
echo -e "==> ${GREEN}Woop woop! Deployed!${RESET}"
else
echo '==> Cancelled by you'
fi