This repository has been archived by the owner on Jan 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
.travis.yml
71 lines (71 loc) · 4.64 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
sudo: required
services:
- docker
cache:
directories:
- "$HOME/google-cloud-sdk/"
env:
global:
- IMAGE=leaguesandbox/nexus
- DOCKER_USERNAME=leaguesandbox
- CLUSTER_NAME=web
- SERVICE_ACCOUNT_NAME=nexus-deploy@league-sandbox.iam.gserviceaccount.com
- DEPLOYMENT_NAME=Nexus
# Docker password
- secure: mzhtN9COt57xBvWquhT1yn7tyxIuLuEKMdKXcXvBaPFAGrhroStIC7X7loLpNAwp/36af+M3rXhl4GWXu+ET+TpbQ5A+OFEauvkbLBYlEZFQxpSVMM2fmbqFc4GR6WJusO6YXCuk0sN1aKGTFct6pihc05BtzUcWaf4hEl3EAtCIdJLdrwqK4SaA6FO8wDx119KRKvm26GZeYGRHsxB7KF9hx/Fqm6mOwkC7Z9TJjvL3xC8KUXfrPs/UEczYMN2Cyx44hbwDTb00FDIbwB1G1+lj1fBrXh8Qy6f1soSQ6taWCZ0rDo4j6rSBpCEIecE07cogOudhCeOX47Hpg1er2ZKEfQhfIEbSEBkeAyyqugHxO4KqjbzgsaBJ6+J/v+XHWbNH4f4+K/SpCRoj1CWd4vEyUy+4wbSvytWJNaAKQrBoYEApPYfMKoSGeEMn7RL1sxhCk7L0FkuaoyAWWgtl65clBW5135FiihpTucSkJnDKsQt6WHsEDKyg119SpQTNptPJB9svsjeCaJiZDm8BJGjutjNECRE/oibw8azNhaHsrfY8ZgUDfEcFMZWML8plWtpblpAl6iKBplIeRIbJaesEJO78VnSNnaKmDarSRiMMolP7FLAi8NgsFj6WEd1wvFDSouIsbyzn2X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lDSISyratB7UEo6DYFbOF/SSQx1uWJaS3ewT9isbiR4XMM81xgGMFe4LuoGkcv31kCF2tyR130S6UlgJJm91nuzNMxUn/TVCLArO73LpH8502etbAtrXRXVc9VqCXYktHpUu3BxWCUdP0/gy3RMm6cBrKrcCssMV0kSEWVxrty6O5Y8al6KOcDg5gLPIIscfj7H/o2l6HzYGidMvwvIwf6SpRVDQ4lBP8hbTqtWT3Bdi8BQ7TvRaQ+7sHxAZ+/3/6v4wl8/4/x3+piKOx8S/BX2Z9fmb4pTIhBBOWBtpSU1kpFpFYm4vfPDTL4gZp2Yrruf37FQaAT8oiL/8Zwc=
jobs:
include:
- stage: test
script:
- docker build --tag $IMAGE:commit-$TRAVIS_COMMIT .
# TODO: Implement test phase
# - >
# docker run
# -e CI=true
# -e TRAVIS=true
# -e CODECOV_TOKEN=$CODECOV_TOKEN
# -e TRAVIS_BRANCH=$TRAVIS_BRANCH
# -e TRAVIS_JOB_NUMBER=$TRAVIS_JOB_NUMBER
# -e TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST
# -e TRAVIS_JOB_ID=$TRAVIS_JOB_ID
# -e TRAVIS_TAG=$TRAVIS_TAG
# -e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG
# -e TRAVIS_COMMIT=$TRAVIS_COMMIT
# -e DEBUG=true
# -e DATABASE_URL=sqlite:////tmp/app-test.db
# --entrypoint "/bin/sh"
# $IMAGE:commit-$TRAVIS_COMMIT
# -c "pip install -r requirements-dev.txt && pytest --cov && pip install codecov && codecov"
- stage: build
script:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD;
- docker build --tag $IMAGE:commit-$TRAVIS_COMMIT .
- docker push $IMAGE:commit-$TRAVIS_COMMIT
- stage: deploy
script:
- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash; fi
- source $HOME/google-cloud-sdk/path.bash.inc
- gcloud components install kubectl
- cd kubernetes
- openssl aes-256-cbc -k "$SERVICE_ACCOUNT_PASSWORD" -in service-account.json.enc -out service-account.json -d
- gcloud auth activate-service-account $SERVICE_ACCOUNT_NAME --key-file=service-account.json --project=league-sandbox
- gcloud config set core/project league-sandbox
- gcloud config set compute/zone europe-north1-a
- gcloud container clusters get-credentials $CLUSTER_NAME
- envsubst '${TRAVIS_COMMIT}' < deployment.yaml.template > deployment.yaml
- kubectl apply -f deployment.yaml
- sleep 10
- kubectl exec -it $(kubectl get pod -l "app=nexus,tier=web" -o jsonpath='{.items[0].metadata.name}' --namespace nexus) --namespace nexus -- python manage.py migrate
- "curl -H 'Content-Type: application/json' -X POST -d '{\"content\": \"'$DEPLOYMENT_NAME' updated, commit hash '$TRAVIS_COMMIT'\"}' $DEPLOY_NOTIFY_WEBHOOK"
stages:
- test
- name: build
if: branch = master AND type = push
- name: deploy
if: branch = master AND type = push
notifications:
email: false