-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.sh
executable file
·40 lines (30 loc) · 864 Bytes
/
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
#!/bin/bash
set -ex
if [[ ${DOCKER} ]]; then
eval "$(ssh-agent -s)"
ssh-add -k ~/.ssh/id_digipulse
cert="/app/.ssh/bot.pem"
else
cert="~/.ssh/bot.pem"
fi
# Install latest packages
yarn
# Build the project for production
yarn build --production --release
# Define local server
nginx_conf="./deploy/react.conf"
dist="./dist"
# Define remote server
host="18.211.182.200"
user="ubuntu"
path="/home/ubuntu/react"
nginx_path="/etc/nginx/sites-available"
remote="ssh -i $cert $user@$host"
# Remove old files
eval $remote "rm -rf $path/*"
# Copy new files
rsync -avz $dist/* -e "ssh -i $cert" $user@$host:$path
# Copy nginx
rsync --rsync-path="sudo rsync" -avz $nginx_conf -e "ssh -i $cert" $user@$host:$nginx_path
eval $remote "sudo ln -fs /etc/nginx/sites-available/react.conf /etc/nginx/sites-enabled/react"
eval $remote "sudo systemctl reload nginx"