-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·46 lines (43 loc) · 1.28 KB
/
deploy.sh
File metadata and controls
executable file
·46 lines (43 loc) · 1.28 KB
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 -euo pipefail
shopt -s inherit_errexit
echo "Deployment tool v1"
echo "Describe the changes in this deployment: "
read changelog
echo "Making sure that all tests pass before deploying..."
echo "Backing up .env"
cp packages/server/.env .env-tmp
echo "Copying test credentials to .env file..."
cat packages/server/.env-test > packages/server/.env
echo "Running tests! This might take a while.."
lerna run test
echo "Restoring .env"
mv .env-tmp packages/server/.env
echo "Pushing changes to GitHub..."
git add .
date +"%D %T"
currentDate=`date`
if git commit -m "deployment($currentDate): $changelog"; then
git push
else
echo "Nothing to commit. Exiting deployment..."
exit 1
fi
echo "Connecting to Droplet & deploying..."
start=$(date +"%s")
ssh root@174.138.58.117 '
cd ~/CovEducation;
git pull;
forever stop 0;
yarn;
lerna run build --stream;
cd packages/server;
forever start -c "nodemon --exitcrash --config nodemon.json" src/index.ts'
end=$(date +"%s")
DIFF=$(($end-$start))
if ping -c 5 www.coved.org; then
echo "New version succesfully deployed! 🎉"
echo "Total downtime: $((($DIFF % 3600) / 60)) minutes $(($DIFF % 60)) seconds"
else
echo "Failed to start DigitalOcean droplet. Please ssh into the droplet to debug."
fi