-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·64 lines (57 loc) · 1.5 KB
/
deploy.sh
File metadata and controls
executable file
·64 lines (57 loc) · 1.5 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash -e
# Check deployment type argument is passed in
if [ "$#" -lt 1 ]; then
echo "Usage $0 [OPTIONS] TYPE"
exit -1
fi
# Get the type and check it is valid
for type; do true; done
if [[ "$type" == "staging" ]]; then
name=smartcourse-staging
elif [[ "$type" == "prod" ]]; then
name=smartcourse
else
echo "Type must be either 'staging' or 'prod'"
exit -1
fi
echo "Zipping..."
# Zip the web app files
rm -f smartcourse.zip
cp scripts/backup.sh .
zip -r smartcourse.zip package.json package-lock.json web.config backup.sh data src scripts
rm backup.sh
echo ""
echo "Deploying..."
curl -u $AZURE_USER:$AZURE_PASS \
--request POST \
--data-binary @smartcourse.zip https://$name.scm.azurewebsites.net/api/zipdeploy
echo ""
echo "Installing modules..."
read -d '' TMP_CMDS << EOF || true
{
"command": "npm install",
"dir": "site/wwwroot"
}
EOF
curl -u $AZURE_USER:$AZURE_PASS \
--header "Content-Type: application/json" \
--request POST \
--data "$TMP_CMDS" \
https://$name.scm.azurewebsites.net/api/command
echo ""
if [[ "$type" == "staging" ]]; then
echo "Adding test data..."
read -d '' TMP_CMDS << EOF || true
{
"command": "node . --drop all --create all --init test",
"dir": "site/wwwroot/scripts/db"
}
EOF
curl -u $AZURE_USER:$AZURE_PASS \
--header "Content-Type: application/json" \
--request POST \
--data "$TMP_CMDS" \
https://$name.scm.azurewebsites.net/api/command
echo ""
fi
echo "DONE!"