-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
92 lines (79 loc) · 3.8 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
language: python
python:
- '2.7'
before_install:
- openssl aes-256-cbc -K $encrypted_8ea223bd84f4_key -iv $encrypted_8ea223bd84f4_iv -in client-secret.json.enc -out client-secret.json -d
- export PYTHONPATH="${PYTHONPATH}:${TRAVIS_BUILD_DIR}/lib"
install:
- git clone https://github.com/psiemens/react-book.git phoenix/static/src/js/react-book
- pip install -r requirements-prd.txt -t lib/
- pip install requests --upgrade -t lib/
- pip install jsonfield==2.0.2 --upgrade -t lib/
# Use deployment settings
- mv _settings/settings-dpl.py phoenix/settings.py
- pip install google-cloud-datastore
- export GOOGLE_APPLICATION_CREDENTIALS="${TRAVIS_BUILD_DIR}/client-secret.json"
- export APP_VERSION=phoenix-${TRAVIS_TAG//./-}
- export SQL_HOST=$(python manage_secret.py SQL_HOST)
- export SQL_USER=$(python manage_secret.py SQL_USER)
- export SQL_PASSWORD=$(python manage_secret.py SQL_PASSWORD)
- export SQL_SOCKET_DIR=/cloudsql
- export SQL_SOCKET=$SQL_SOCKET_DIR/$SQL_HOST
- export SQL_DATABASE_OLD=$(python manage_secret.py SQL_DATABASE_OLD)
- export SQL_DATABASE_CURRENT=$(python manage_secret.py SQL_DATABASE)
- export SQL_DATABASE_NEW=$APP_VERSION
# Install Cloud SQL Proxy
- wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
- chmod +x cloud_sql_proxy
- sudo mkdir $SQL_SOCKET_DIR
- sudo chmod 777 $SQL_SOCKET_DIR
- cd phoenix/static
- yarn setup
script:
- yarn build
after_success:
- cd $TRAVIS_BUILD_DIR
- mv _settings/settings-dpl.py phoenix/settings.py
- mkdir ${TRAVIS_BUILD_DIR}/gcs
- rm -rf phoenix/static/node_modules phoenix/static/src
# Collect static files
- python manage.py collectstatic --noinput
- find ${TRAVIS_BUILD_DIR}/gcs -type f -exec gzip "{}" \; -exec mv "{}.gz" "{}" \;
- gcloud auth activate-service-account [email protected] --key-file=client-secret.json --project=phoenix-prd
# Clone database and run migrations
# If migration is succesful, delete old backup
- if [ -n $TRAVIS_TAG ]; then
./cloud_sql_proxy -instances=$SQL_HOST -dir=$SQL_SOCKET_DIR -credential_file=client-secret.json &
sleep 5 &&
mysqldump -S $SQL_SOCKET -u $SQL_USER -p$SQL_PASSWORD --single-transaction --no-create-db --set-gtid-purged=OFF $SQL_DATABASE_CURRENT > phoenix.sql &&
mysqladmin -S $SQL_SOCKET -u $SQL_USER -p$SQL_PASSWORD create $SQL_DATABASE_NEW &&
mysql -S $SQL_SOCKET -u $SQL_USER -p$SQL_PASSWORD $SQL_DATABASE_NEW < phoenix.sql &&
python manage.py migrate;
fi
# Use production settings
- rm phoenix/settings.py phoenix/settings.pyc
- mv _settings/settings-prd.py phoenix/settings.py
# Cleanup
- rm -rf .git _settings cloud_sql_proxy phoenix/static/node_modules phoenix.sql
- pip install google-cloud-storage -t lib/
deploy:
- provider: gcs
access_key_id: GOOG6VXJ7FN5TYTTPSQI
secret_access_key:
secure: cbcoLAJoj6/oH/oDXGowEOQC/HU3EPEJYkQMb3syaL458U5/gVUjQYB1k0KC6u6Md8fvFnmo94uod/S70Q4Mhnka5HDMu3duf8Yk82Tw/6AbrLNXriSZEcM5qzoDXbNlghKvsxOaGjA/jD+wKWQkgEfhWc2+Jodi27jDjBq72MKvTv0gTZn6kNZSuteLEGqpN/JV4DetULsmPb9lHHBs7Ng1/h3aOtNYK2GVOHCklQ8kf78SAcrbT3lr7mJYO6NFT/Yp20cghegEfq1OdPYtNFZKS8alWTUIs1WF/ywErr+lSo8YyRkdEk398w2rpq4EDqdwWs6Ah/LaA60DeP06zfuxptR2ulQfJ2vdij2gq4JG+loF7yrzBcdEOfuqX/Rw2j7OoS08A1ECrmdUyw1966/h5tuqunUoh3bDE6H37H+pPR84adpZ2w94wdluVFQ8mNg3BurCCNUNPyEO3jKzke2paO9MK9CTcHLuPY0xQraQF9JxEXPUT5GBnbQzU4zY4aXyiftxPREtYTvpnk7AQN2zo5lfiWel4vSJOUrQXf1ZtK5iV8SjRWoqxmPbrREZjp0S8K3O7EsOFmIwB3h36YuSP8sm6ktMg/mzt7q/7x4wYJAa3rTxAl2ku0FwIHF45py5B6FnYw93mNd7vg77U2KJoovlCJCzw6tflFIR+O4=
bucket: phoenix-news
skip_cleanup: true
acl: public-read
local-dir: $TRAVIS_BUILD_DIR/gcs
detect_encoding: true
cache_control: "max-age=31536000"
on:
tags: true
- provider: gae
keyfile: client-secret.json
project: phoenix-prd
default: true
version: $APP_VERSION
skip_cleanup: true
on:
tags: true