-
Notifications
You must be signed in to change notification settings - Fork 449
/
deploy.sh
49 lines (42 loc) · 1.57 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
#!/usr/bin/env bash
# Travis build triggered on a forked repository
if [ "$TRAVIS_REPO_SLUG" != "anitab-org/mentorship-backend" ]; then
echo "Skip publishing, this is a forked repo."
exit 0
fi
# Travis build triggered by a PR
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Skip publishing, just a PR."
exit 0
fi
# Checking branch
if [ "$TRAVIS_BRANCH" == "develop" ]; then
FLASK_ENVIRONMENT_CONFIG="dev"
SERVER="Development"
elif [ "$TRAVIS_BRANCH" == "master" ]; then
FLASK_ENVIRONMENT_CONFIG="prod"
SERVER="Production"
else
echo "Skip publishing, we don't publish for branches other than develop and master."
exit 0
fi
# Get the latest code
cd $HOME
git clone --branch=$TRAVIS_BRANCH https://github.com/anitab-org/mentorship-backend.git
cd mentorship-backend
# Create AWS Elastic Beanstalk profile
mkdir ~/.aws
echo "[profile eb-cli]" > ~/.aws/config
echo "aws_access_key_id = $AWS_ACCESS_ID" >> ~/.aws/config
echo "aws_secret_access_key = $AWS_SECRET_KEY" >> ~/.aws/config
# Add environment variables
eb setenv FLASK_ENVIRONMENT_CONFIG=$FLASK_ENVIRONMENT_CONFIG MAIL_DEFAULT_SENDER=$MAIL_DEFAULT_SENDER MAIL_SERVER=$MAIL_SERVER APP_MAIL_USERNAME=$APP_MAIL_USERNAME APP_MAIL_PASSWORD=$APP_MAIL_PASSWORD SECRET_KEY=$SECRET_KEY SECURITY_PASSWORD_SALT=$SECURITY_PASSWORD_SALT DB_TYPE=$DB_TYPE DB_USERNAME=$DB_USERNAME DB_PASSWORD=$DB_PASSWORD DB_ENDPOINT=$DB_ENDPOINT DB_NAME=$DB_NAME
# Publishing
echo "Publishing to '$SERVER' server"
eb deploy
if [ $? -eq 0 ]; then
echo "Publishing successful."
else
echo "Publishing failed."
exit 2
fi