Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Deploy via Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
leelongmore committed Nov 7, 2017
1 parent 75d8c4a commit 5d19bbf
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 9 deletions.
41 changes: 32 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,49 @@ python:
- "2.7"
cache: pip
sudo: false
notifications:
email: false

# Need mongodb for testing
services: mongodb
# command to install dependencies

install:
- pip install --upgrade pip
- easy_install distribute
- pip install --upgrade distribute
- pip install --upgrade setuptools
- pip install -q -r requirements_for_tests.txt
# command to run tests

env:
- SKIP_VIRUS_SCAN=1 SKIP_SPLINTER_TESTS=1 MONGO_REPLICA_SET='' NO_AUTOPEP8=1
global:
- SKIP_VIRUS_SCAN=1 SKIP_SPLINTER_TESTS=1 MONGO_REPLICA_SET='' NO_AUTOPEP8=1
- PAAS_USER=pp-deploy@digital.cabinet-office.gov.uk
# PAAS_PASSWORD
- secure: HNo6rnNiXmNYAV1TvkcMxeniXpmHoZkNEiT+X9EgyInCOnVm4mz89qi/AElY/ESE5HdYIegJ5l1M5tAWCei4dSDSTSfkbBBiHE6dfpf1OSU857oQ6T6161NRg4V2oxNdWSRgAX+G8rpxBShaXCDU9q9iBxhsqrmTX+UGlzKloDk=
# APP_SIGNON_API_USER_TOKEN_STAGING
- secure: PYLrm6uH6uhNA69xgI5lSXLrX0ouPBdxlMlQXER0K2BkHzxTowNDFyf5LDa2kwIueJ/YXFHAgm7eBN9gr3JIXAN8Mqb15LTHJVg6hc2aLwFZKES4fuPa/da3Pn24xrdTesIedUAv2vSkuacaktZwKxsv6LENw53uA+8kOT8l9SQ=
# APP_SIGNON_API_USER_TOKEN_PRODUCTION
- secure: SBk+7zw2GMkgbl8p7hwXZw5VkDf2FQE4kBklD40c7goORyEF3/FjTVJTVlREN4Rwb3a81N5lkQDl0fLPhGaDv+PyTr+l69IU64w1Whu9e9fL/wMC3zo5Eer3Btptar5jdCsEg+V4woKKXv6j4B4xebHN6sU7C6dX9TGKs+R1aBo=

script:
- ./run_tests.sh

after_script:
- coveralls
branches:
except:
- release
- /^release_[0-9]+$/
- /^deployed-to-(preview|staging|production)$/
notifications:
email: false

before_deploy:
- chmod +x etc/deploy.sh

deploy:
- provider: script
script: APP_SIGNON_API_USER_TOKEN=$APP_SIGNON_API_USER_TOKEN_STAGING etc/deploy.sh staging
skip_cleanup: true
on:
branch: staging

- provider: script
script: APP_SIGNON_API_USER_TOKEN=$APP_SIGNON_API_USER_TOKEN_PRODUCTION etc/deploy.sh production
skip_cleanup: true
on:
branch: production
36 changes: 36 additions & 0 deletions etc/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -e

if [ -z "$1" ]; then
echo "Missing PAAS space argument"
echo " deploy.sh staging|production"
exit 1
fi

PAAS_SPACE=$1
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb http://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update && sudo apt-get install cf-cli

cf login -u $PAAS_USER -p $PAAS_PASSWORD -a https://api.cloud.service.gov.uk -o gds-performance-platform -s $PAAS_SPACE

# bind services
cf bind-service performance-platform-backdrop-read gds-performance-platform-mongodb-service
cf bind-service performance-platform-backdrop-write gds-performance-platform-mongodb-service

# set environmental variables
cf set-env performance-platform-backdrop-read ENVIRONMENT $PAAS_SPACE
cf set-env performance-platform-backdrop-read STAGECRAFT_URL https://performance-platform-stagecraft-$PAAS_SPACE.cloudapps.digital
cf set-env performance-platform-backdrop-read SIGNON_API_USER_TOKEN $APP_SIGNON_API_USER_TOKEN

cf set-env performance-platform-backdrop-write ENVIRONMENT $PAAS_SPACE
cf set-env performance-platform-backdrop-write STAGECRAFT_URL https://performance-platform-stagecraft-$PAAS_SPACE.cloudapps.digital
cf set-env performance-platform-backdrop-write SIGNON_API_USER_TOKEN $APP_SIGNON_API_USER_TOKEN

# deploy apps
cf push -f manifest.yml

# create and map routes
cf map-route performance-platform-backdrop-read cloudapps.digital --hostname performance-platform-backdrop-read-$PAAS_SPACE
cf map-route performance-platform-backdrop-write cloudapps.digital --hostname performance-platform-backdrop-write-$PAAS_SPACE
18 changes: 18 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
buildpack: python_buildpack
name: performance-platform-backdrop
services:
- gds-performance-platform-mongodb-service
memory: 256M
applications:
- name: performance-platform-backdrop-read
command: python start.py read 8080
instances: 1
memory: 512M
health-check-type: none

- name: performance-platform-backdrop-write
command: python start.py write 8080
instances: 1
memory: 512M
health-check-type: none

0 comments on commit 5d19bbf

Please sign in to comment.