forked from StreetSupport/streetsupport-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-website.sh
More file actions
81 lines (64 loc) · 1.84 KB
/
deploy-website.sh
File metadata and controls
81 lines (64 loc) · 1.84 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# If there are any errors, fail Travis
set -e
# Set settings for develop environment by default.
AZURE_WEBSITE=$DEV_AZURE_WEBSITE
APP_INSIGHTS_KEY=''
APIENVIRONMENT=1
# Define variables depending on the branch
if [[ $TRAVIS_BRANCH == 'release' ]]
then
AZURE_WEBSITE=$PROD_AZURE_WEBSITE
APP_INSIGHTS_KEY=$PROD_APP_INSIGHTS_KEY
APIENVIRONMENT=3
fi
if [[ $TRAVIS_BRANCH == 'uat' ]]
then
AZURE_WEBSITE=$UAT_AZURE_WEBSITE
APP_INSIGHTS_KEY=$UAT_APP_INSIGHTS_KEY
APIENVIRONMENT=2
fi
# Get the commit details
THE_COMMIT=`git rev-parse HEAD`
# Set git details
git config --global user.email "enquiry@streetsupport.net"
git config --global user.name "Travis CI"
# Set environment
cd src/js
rm env.js
cat > env.js << EOF
module.exports = $APIENVIRONMENT
EOF
echo "env.js file rewritten to:"
cat env.js
cd ../../
# Create version.txt
DATE=`date +%Y%m%d%H%M`
cd src/files
cat > version.txt << EOF
$DATE
EOF
cd ../../
# Set appInsightsKey
cd src/data
sed -i.bak "s/\"appInsightsKey\": \".*\"/\"appInsightsKey\": \"$APP_INSIGHTS_KEY\"/" site.json
cd ../../
# Run gulp
gulp deploy --debug --production
if [[ $TRAVIS_PULL_REQUEST == 'false' ]]
then
# Move to created directory
cd _dist
if [[ $TRAVIS_BRANCH == 'release' ]] || [[ $TRAVIS_BRANCH == 'uat' ]] || [[ $TRAVIS_BRANCH == 'develop' ]]
then
git init
git add -A
git commit -m "Travis CI automatic build for $THE_COMMIT"
# Push to git by overriding previous commits
# IMPORTANT: Supress messages so nothing appears in logs
echo "pushing to ${AZURE_WEBSITE}"
git push --quiet --force "https://${AZURE_USER}:${AZURE_PASSWORD}@${AZURE_WEBSITE}.scm.azurewebsites.net:443/${AZURE_WEBSITE}.git" master > /dev/null 2>&1
else
echo "Not on a build branch so don't push the changes to GitHub Pages"
fi
fi