-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
63 lines (48 loc) · 1.74 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
#!/bin/bash
exitWithMessageOnError () {
if [ ! $? -eq 0 ]; then
echo "An error has occurred during web site deployment."
echo $1
exit 1
fi
}
# Prerequisites
# -------------
# Verify node.js installed
hash node 2>/dev/null
exitWithMessageOnError "Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment."
# Setup
# -----
SCRIPT_DIR=`pwd`
DEPLOYMENT_SOURCE=$SCRIPT_DIR
DEPLOYMENT_TEMP="$SCRIPT_DIR/../temp"
DEPLOYMENT_TARGET="$SCRIPT_DIR/../wwwroot"
# Install kudu sync
echo Installing Kudu Sync
npm.cmd install kudusync -g --silent
exitWithMessageOnError "kudusync install failed"
##################################################################################################################################
# Deployment
# ----------
echo "Handling Angular deployment."
# 1. Copying the repository to temp
echo "Copying the repository to temp"
kudusync -v 50 -f ${DEPLOYMENT_SOURCE} -t ${DEPLOYMENT_TEMP} -i ".git;.deployment;deploy.sh" -x
exitWithMessageOnError "Repository could not be copied to temp"
# 2. Installing dependencies
echo "Installing dependencies"
pushd "$DEPLOYMENT_TEMP"
npm.cmd install
exitWithMessageOnError "npm failed"
popd
# 3. Building the Angular application
echo "Building the Angular application"
pushd ${DEPLOYMENT_TEMP}
./node_modules/.bin/ng build --target=production
exitWithMessageOnError "build failed"
popd
# 4. Copying the contents of temp/dist to /wwwroot
kudusync -v 50 -f ${DEPLOYMENT_TEMP}/dist -t ${DEPLOYMENT_TARGET} -x
exitWithMessageOnError "Copying to /wwwroot failed."
##################################################################################################################################
echo "Finished successfully."