Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Commit

Permalink
Add autodeploy strategy to make/travis
Browse files Browse the repository at this point in the history
  • Loading branch information
brew committed May 23, 2018
1 parent d5beaab commit 1a3c49a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ language: node_js
node_js:
- '7.7'

services:
- docker

env:
- NODE_ENV="test" DB_USER="postgres" CXX=g++-4.8
global:
# DOCKER_USERNAME
- secure: IXZ8Jskg91eCRgY2a3VmIAo1kCpmeiwnuPOdBYFXzlDRL/gp0k7p4LeyCsP+ztVhNg8Yg3RhcRNhg4Jzfl/TKXQHlel4EL+SXZrgux1i1+zvzsl2syPj53PswlFh3WCzovUjfPnYzU1bIS6R1xDGzUKcWNdAXJ735aVvqYh0RCQ=
# DOCKER_PASSWORD
- secure: JMF9r9a6GgIWgnjI6IgfdqcTfii4MO6/DHhH1bIqruIoVwNe+y4ioIS7/OPw6jQ43uvaFMpbourTBgcOyju0/e5B5gpktPb+Wq0LHcI58C5N7a0IsdltvrNjC7aIliuMcbPsdnVUeD3jbcz80vqPaJcOs23P6gUro0ArbwsMAn0=

addons:
postgresql: "9.4"
Expand All @@ -18,3 +26,13 @@ before_script:
- psql -c 'create database opendatacensus_test;' -U postgres

after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"

after_success:
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then make ci-push-tag TAG="${TRAVIS_PULL_REQUEST_BRANCH////_}"; fi'

deploy:
# deploy master to latest tag
- provider: script
script: make ci-push
on:
branch: master
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
REPOSITORY := 'openknowledge/opendatasurvey'
SHELL := /bin/bash

NAME := opendatasurvey
ORG := openknowledge
REPO := ${ORG}/${NAME}
TAG := $(shell git log -1 --pretty=format:"%h")
IMG := ${REPO}:${TAG}
LATEST := ${REPO}:latest


help: # http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

Expand Down Expand Up @@ -41,3 +49,14 @@ deploy: build login push

server: ## command to run the command as queue or server
npm start

ci-push: ci-login ## push tagged and latest images to DockerHub (used by Travis)
docker push ${IMG}
docker push ${LATEST}

ci-push-tag: ci-login ## build and push tagged image to DockerHub (used by Travis)
docker build -t ${REPO}:${TAG} .
docker push ${REPO}:${TAG}

ci-login: ## login to DockerHub with credentials found in env (used by Travis)
docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}

0 comments on commit 1a3c49a

Please sign in to comment.