-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.sh
executable file
·68 lines (52 loc) · 2.24 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
67
68
#!/bin/bash
# In a test environment, run this script as follows:
# 1) Change to the repo containing the documentation (cd ~/docs)
# 2) Place this script inside the repo directory
# 3) Run ./deploy.sh . _build/html
#
# Uncomment the following two lines for testing:
#TRAVIS_PULL_REQUEST="false"
#DEPLOY_BUCKET="gyro.dev"
#
# Scenario 1: deploying a previous release. Uncomment the following:
# TRAVIS_BRANCH=release/3.2
# Scenario 2: deploying the current release. Uncomment the following:
#TRAVIS_BRANCH=master
#
set -e -u
# Sphinx Build
sudo pip install --upgrade pip==19.2.3
sudo pip install -r requirements.txt
# Retain current directory passed from command line.
BUILD_DIRECTORY=`pwd`/$1
# Rename original Pygments files that produced lexer errors, and sym-link to the custom
# lexers that provide better results. The source files for those custom lexers
# are at https://github.com/markperfectsensedigital/custom_lexers
#cd /usr/local/lib/python2.7/dist-packages/pygments/lexers/
#sudo mv templates.py templates.py.old
#sudo mv css.py css.py.old
#sudo ln -s /usr/local/lib/python2.7/dist-packages/pygments-lexer-overrides/css.py css.py
#sudo ln -s /usr/local/lib/python2.7/dist-packages/pygments-lexer-overrides/templates.py templates.py
# Change to the build directory and launch the job.
cd $BUILD_DIRECTORY
sh ./generate-provider-docs.sh
make html
# If this Travis job is not a pull request,
# assume it is a merge and deploy to S3
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then
sudo pip install awscli --ignore-installed
echo "Deploying to bucket: $DEPLOY_BUCKET"
if [[ "$TRAVIS_BRANCH" == "release/"* ]]; then
version=$(awk -F '/' '{print $2}' <<< $TRAVIS_BRANCH)
echo "Synching for release $version..."
aws s3 sync _build/html s3://$DEPLOY_BUCKET/v$version --acl public-read --cache-control max-age=3600 --delete
echo "Done synching release $version"
fi
if [[ "$TRAVIS_BRANCH" == "master" ]]; then
echo "Synching master..."
aws s3 sync _build/html s3://$DEPLOY_BUCKET/ --acl public-read --include "*" --exclude "v?.?/*" --delete --profile psd-gyro
echo "Done syching master"
fi
else
echo "As this build was for Pull Request $TRAVIS_PULL_REQUEST, there was no deployment to AWS."
fi