Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #477 from jcscottiii/master
Browse files Browse the repository at this point in the history
Move from Travis to CircleCI
  • Loading branch information
Marco Segreto committed Jul 20, 2016
2 parents 891e9d1 + 17e8797 commit 1bd876a
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -18,7 +18,7 @@ script:
before_deploy:
- export BUILD_INFO=build::$TRAVIS_BRANCH::$(date -u "+%Y-%m-%d-%H-%M-%S")::$TRAVIS_BUILD_NUMBER::$(deploy/npm-version.sh)
# Extract any encrypted env vars and put them into the manifests/manifest-master.yml
- python deploy/travis-vars-to-manifest.py
- python deploy/vars-to-manifest.py
# Download the go-bindata binary, which is necessary for the CF CLI
- go get -u github.com/jteeuwen/go-bindata/...
- export GOBINDATA_BIN=$(which go-bindata)
Expand Down
55 changes: 55 additions & 0 deletions circle.yml
@@ -0,0 +1,55 @@
machine:
environment:
GODIST: "go1.6.linux-amd64.tar.gz"
WS: "/home/ubuntu/.go_workspace/src/github.com/18F/cg-deck"
CF_API: "https://api.cloud.gov"
CF_ORGANIZATION: "cf"
CF_API_GC: "https://api.fr.cloud.gov"
CF_ORGANIZATION_GC: "cloud-gov"
post:
- cd cg-deck && nvm install && nvm use && nvm alias default $(nvm current)
- mkdir -p download
- test -e download/$GODIST || curl -o download/$GODIST https://storage.googleapis.com/golang/$GODIST
- sudo rm -rf /usr/local/go
- sudo tar -C /usr/local -xzf download/$GODIST

dependencies:
cache_directories:
- "$WS/node_modules/"
pre:
- sudo apt-get update; sudo apt-get install libicu52
- curl --output /home/ubuntu/bin/phantomjs-2.0.1-linux-x86_64-dynamic https://s3.amazonaws.com/circle-support-bucket/phantomjs/phantomjs-2.0.1-linux-x86_64-dynamic
- chmod a+x /home/ubuntu/bin/phantomjs-2.0.1-linux-x86_64-dynamic
- sudo ln -s --force /home/ubuntu/bin/phantomjs-2.0.1-linux-x86_64-dynamic /usr/local/bin/phantomjs
- go version
- go get github.com/Masterminds/glide
- mkdir -p $WS && cp -R /home/ubuntu/cg-deck/. $WS
- cd $WS && glide install
- cd $WS && npm install
override:
- cd $WS && go build
- cd $WS && npm run build
test:
pre:
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
- if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
override:
- cd $WS && ./codecheck.sh -u
- cd $WS && npm test

deployment:
deploy:
branch: [master, staging, deprecated]
owner: 18F
commands:
- pip install --user ruamel.yaml
- export BUILD_INFO=build::$CIRCLE_BRANCH::$(date -u "+%Y-%m-%d-%H-%M-%S")::$CIRCLE_BUILD_NUM::$(deploy/npm-version.sh) && python deploy/vars-to-manifest.py
- chmod a+x deploy/circle_deploy.sh && deploy/circle_deploy.sh
production:
tag: /[0-9]+(\.[0-9]+)*/
owner: 18F
commands:
- pip install --user ruamel.yaml
- export BUILD_INFO=build::$CIRCLE_BRANCH::$(date -u "+%Y-%m-%d-%H-%M-%S")::$CIRCLE_BUILD_NUM::$(deploy/npm-version.sh) && python deploy/vars-to-manifest.py
- chmod a+x deploy/circle_deploy.sh && deploy/circle_deploy.sh
69 changes: 69 additions & 0 deletions deploy/circle_deploy.sh
@@ -0,0 +1,69 @@
#!/bin/bash

# This script will install the autopilot plugin, login, pick the right manifest and deploy the app with 0 downtime.

# Command line arguments
# $1 = specified org
# $2 = manifest file path
# $3 = file path to project

set -e

curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&source=github'
sudo dpkg -i cf-cli_amd64.deb
cf -v

# Install autopilot
go get github.com/contraband/autopilot
cf install-plugin -f /home/ubuntu/.go_workspace/bin/autopilot



# Note: Spaces and deployer account username are the same in different environments.
# Only the organization, api, deployer account password differ.


CF_PATH="."
if [[ "$CIRCLE_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]
then
CF_MANIFEST="manifest-prod.yml"
CF_SPACE="deck-prod"
CF_APP="cf-deck"
elif [ "$CIRCLE_BRANCH" == "master" ]
then
CF_MANIFEST="manifest-master.yml"
CF_SPACE="deck-stage"
CF_APP="cf-deck"
elif [ "$CIRCLE_BRANCH" == "staging" ]
then
CF_MANIFEST="manifest-staging.yml"
CF_SPACE="deck-stage"
CF_APP="cf-deck-staging"
elif [ "$CIRCLE_BRANCH" == "deprecated" ]
then
CF_MANIFEST="manifest-deprecated.yml"
CF_SPACE="deck-prod"
CF_APP="cg-deck"
else
exit
fi

echo $CF_MANIFEST
echo $CF_SPACE


# Log in to east-west
cf api $CF_API
cf auth $CF_USERNAME $CF_PASSWORD && $CF_BIN target -o $CF_ORGANIZATION -s $CF_SPACE
# Set manifest path for eastwest
MANIFEST_PATH=manifests/eastwest/$CF_MANIFEST
# Run autopilot plugin
cf zero-downtime-push $CF_APP -f $MANIFEST_PATH -p $CF_PATH

# Log in to govcloud
cf api $CF_API_GC
cf auth $CF_USERNAME $CF_PASSWORD_GC && $CF_BIN target -o $CF_ORGANIZATION_GC -s $CF_SPACE
# Set manifest path for eastwest
MANIFEST_PATH=manifests/govcloud/$CF_MANIFEST
# Run autopilot plugin
cf zero-downtime-push $CF_APP -f $MANIFEST_PATH -p $CF_PATH
File renamed without changes.

0 comments on commit 1bd876a

Please sign in to comment.