Code Monkey home page Code Monkey logo

cicd-c16's Introduction

Travis and Heroku CICD setup in a nutshell

Also available in a Gist

Setup Continuous Integration with Travis CI

Make sure your repo is ready to go On your local machine:

  • Run npm test to ensure tests are working correctly locally
  • Add properly configured .travis.yml (see below)
    language: node_js
    node_js: node
    services:
    - mongodb
  • Commit and push repo to Github

Activate Travis integration on your repo On Travis - activate integration:

  • Go to Profile: User (in upper-right) > Accounts
  • Click "Sync Account"
  • Activate repo

On GitHub - verify integration and test:

  • Go to Settings > Integrations & Services
    • There should be an entry for "Travis CI" under Services
    • Click the "edit" button, then click "Test service" to test integration

On Travis:

  • Watch build complete successfully :-)

Setup Continuous Deployment to Heroku

Install Travis and Heroku CLIs

Install Travis CI's CLI:

Install Heroku CLI:

Problems installing? Try the Heroku NPM package npm install -g heroku-cli

On Command line Configure .travis.yml to deploy to Heroku:

  • Go to project:
    • Run: CD <YOUR PROJECT>
  • Login to Heroku
    • Run: heroku login (and enter your UN/PW)
  • Create an app
    • Run: heroku create <app-name>
  • Login to travis
    • Run: travis login (and enter your UN/PW for GitHub)
  • Add Heroku info to .travis.yml, run:
    • Run: travis setup heroku
    • Follow prompts, make sure the app name and repo are correct
    • Your .travis.yml should look like this:
      language: node_js
      node_js: node
      services:
      - mongodb
      deploy:
        provider: heroku
        api_key:
          secure: oOa1TMdgeY5+rySYW0HY30j+ot+KUqs1H...
        app: <APP-NAME-ON-HEROKU>
        on:
          repo: <GITHUB-USERNAME>/<REPO-NAME>
  • Ensure tests are still working
    • Run: npm test
  • Commit and push changes to GitHub
    • Run git commit -am "setup CICD"
  • Changes should deploy to GitHub > Travis CI > Heroku

On Heroku Add mLab connection string to (Environment) Config Vars

  • Go to: Personal Apps > PROJECT NAME > Settings
  • Click "Reveal Config Vars"
  • Enter "DATABASE_URL" and your mlab connection string
    • mongodb://<un>:<pw>@ds123456.mlab.com:23456/demodb

Extras Add a Travis CI badge to your repo

  • On Travis CI, find your project and click on the badge
  • Change the dropdown menu to "Markdown" and copy the output
  • Add the badge code to your readme.md file, commit and push
  • The code looks something like this:
[![Build Status](https://travis-ci.org/<USERNAME>/<REPO-NAME>.svg?branch=master)](https://travis-ci.org/<USERNAME>/<REPO-NAME>)```

cicd-c16's People

Contributors

cklanac avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.