-
Notifications
You must be signed in to change notification settings - Fork 11
/
.travis.yml
96 lines (80 loc) · 3.39 KB
/
.travis.yml
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
language: python
python:
- "3.6"
sudo: required
services:
- docker
env:
- DOCKER_COMPOSE_VERSION=1.23.2
before_install:
- pip3 install yapf
- yapf -d -r .
install:
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
- sudo pip install awscli
before_script:
- cp .env.travis .env
- docker-compose up -d
- sleep 120
- docker-compose exec web python manage.py createindex
- docker-compose exec web python manage.py upgrade
- docker-compose exec web python manage.py setup
script:
- docker-compose exec web python manage.py test rorapi.tests
- docker-compose exec web python manage.py test rorapi.tests_integration
- docker-compose exec web python manage.py test rorapi.tests_functional
after_success:
- export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY
- export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_KEY
- docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
- REPO=rorcommunity/ror-api;
- AUTO_DEPLOY=false;
- if [ "${TRAVIS_TAG?}" ]; then
docker build -f Dockerfile -t $REPO:$TRAVIS_TAG .;
docker push $REPO:$TRAVIS_TAG;
echo "Pushed to" $REPO:$TRAVIS_TAG;
AUTO_DEPLOY=true;
elif [[ "$TRAVIS_BRANCH" == "dev" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then
docker build -f Dockerfile -t $REPO:$TRAVIS_BRANCH .;
docker push $REPO:$TRAVIS_BRANCH;
echo "Pushed to" $REPO:$TRAVIS_BRANCH;
AUTO_DEPLOY=true;
else
docker build -f Dockerfile -t $REPO:$TRAVIS_BRANCH .;
docker push $REPO:$TRAVIS_BRANCH;
echo "Pushed to" $REPO:$TRAVIS_BRANCH;
fi
- if [ "$AUTO_DEPLOY" == "true" ]; then
wget https://github.com/jwilder/dockerize/releases/download/v0.6.0/dockerize-linux-amd64-v0.6.0.tar.gz;
tar -xzvf dockerize-linux-amd64-v0.6.0.tar.gz;
rm dockerize-linux-amd64-v0.6.0.tar.gz;
export GIT_SHA=$(git rev-parse --short HEAD);
export GIT_TAG=$(git describe --tags $(git rev-list --tags --max-count=1));
git clone "https://${TRAVIS_SECURE_TOKEN}@github.com/ror-community/new-deployment.git";
sentry-cli releases new ror-api:${GIT_TAG} --finalize --project ror-api;
if [ "${TRAVIS_TAG?}" ]; then
./dockerize -template vendor/docker/_ror-api.auto.tfvars.tmpl:new-deployment/ror/services/api/_ror-api.auto.tfvars;
sentry-cli releases deploys ror-ap:${GIT_TAG} new -e production;
else
./dockerize -template vendor/docker/_ror-api-dev.auto.tfvars.tmpl:new-deployment/ror/services/api/_ror-api-dev.auto.tfvars;
sentry-cli releases deploys ror-api:${GIT_TAG} new -e dev;
fi
sentry-cli releases set-commits --auto ror-api:${GIT_TAG};
cd new-deployment;
git remote;
git config user.email ${DOCKER_EMAIL};
git config user.name ${DOCKER_USERNAME};
if [ "${TRAVIS_TAG?}" ]; then
git add ror/services/api/_ror-api.auto.tfvars;
git commit -m "Adding ror-api git variables for commit tagged ${TRAVIS_TAG?}";
else
git add ror/services/api/_ror-api-dev.auto.tfvars;
git commit -m "Adding ror-api git variables for latest commit on branch $TRAVIS_BRANCH";
fi
git push "https://${TRAVIS_SECURE_TOKEN}@github.com/ror-community/new-deployment.git" master;
fi
notifications:
email: false