-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish
executable file
·72 lines (64 loc) · 1.93 KB
/
publish
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
67
68
69
70
71
72
#!/bin/sh
# Some colors for the output
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Clean up the dist folder
rm -rf dist/keystone-adventure
# Check if production or staging
production=false
while getopts 'p' opt; do
production=true
done
shift "$(($OPTIND -1))"
# Set the configuration variable
configuration="staging"
if [[ "$production" = true ]]
then
configuration="production"
fi
# Generate the matching bundle
echo "${GREEN}»»» Generating $configuration bundle «««${NC}"
ng build --configuration $configuration
# Clean up the remote playground folder
remote="[email protected]"
echo "\n${GREEN}»»» Cleaning remote directories «««${NC}\n"
echo " » Local system name: $HOSTNAME"
echo " » Local date and time: $(date)"
folder="public_html/registration"
if [[ "$production" = true ]]
then
folder="public_html/program"
echo "\n${GREEN}»»» Running commands on remote host named $remote folder 'public_html/program' «««${NC}\n"
ssh -T $remote <<'EOL'
now="$(date)"
name="$HOSTNAME"
up="$(uptime)"
echo " » Server name is $name"
echo " » Server date and time is $now"
echo " » Server uptime: $up"
cd public_html/program
rm *.js manifest.* ngsw.json *.css index.html favicon.ico
[ ! -e *.map ] || rm *.map
rm -rf assets/
echo "Bye"
EOL
else
echo "\n${GREEN}»»» Running commands on remote host named $remote folder 'public_html/registration' «««${NC}\n"
ssh -T $remote <<'EOL'
now="$(date)"
name="$HOSTNAME"
up="$(uptime)"
echo " » Server name is $name"
echo " » Server date and time is $now"
echo " » Server uptime: $up"
cd public_html/registration
rm *.js manifest.* ngsw.json *.css index.html favicon.ico
[ ! -e *.map ] || rm *.map
rm -rf assets/
echo "Bye"
EOL
fi
# Publish to the correct subdomain
echo "\n${GREEN}»»» Publishing $configuration bundle to $remote:$folder «««${NC}\n"
rsync -azvh dist/keystone-registration/ $remote:$folder