-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdeploy.sh
66 lines (38 loc) · 1.2 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Rebuild site
rm -rf ./public
npx gulp build
# Read Sitehost username from .env
set -o allexport
source .env
set +o allexport
# Set production flag to FALSE by default
production=false
# Set production flag to TRUE if -P flag was passed
while getopts ':P' opt; do
case ${opt} in
P) production=true
esac
done
if [[ "$production" = true ]]; then
# Run Hugo in production mode
export HUGO_ENV="production"
hugo --baseURL $HUGO_BASE_URL_LIVE
# Require confirmation for production deployment
echo "[rsync] Confirm production deployment by entering 'ok', enter 'no' to cancel:"
read ok_no
if [[ "$ok_no" = "ok" ]]; then
# Deployment confirmed, deploy to Sitehost
echo "[rsync] Deploying to Sitehost..."
rsync -av --delete ./public/ "[email protected]:/groups/$SITEHOST_USERNAME/web/"
else
# Deployment cancelled
echo "[rsync] Deployment cancelled"
fi
else
# Run Hugo in test (development) mode
hugo --baseURL $HUGO_BASE_URL_TEST
# Deploy to Sitehost-Test
echo "[rsync] Deploying to Sitehost-Test..."
rsync -av --delete ./public/ "[email protected]:/groups/$SITEHOST_USERNAME/web/"
fi