Skip to content

Instantly share code, notes, and snippets.

@sassygrody
Created December 10, 2021 16:00
Show Gist options
  • Save sassygrody/207d49749115f2d4e9c57e51804fe16c to your computer and use it in GitHub Desktop.
Save sassygrody/207d49749115f2d4e9c57e51804fe16c to your computer and use it in GitHub Desktop.

DevOps Day!

Dependencies

  • A personal Github account
  • A personal Codeship account
  • A personal Heroku account
  • A Rails development environment
    • rbenv or rvm
    • Rails gem globally installed
  • A command line interface

Expectations:

  • Setting up CI/CD with a Rails Github repo, Codeship CI/CD, and Heroku hosting
  • Configure a single (staging) environment
    • Configure a secondary (prod) environment if time allows
  • Encounter some errors to replicate a more realistic pipeline creation :)

Steps

  1. Create a new rails app
    1. rails new devops-day --database=postgresql --T
    2. https://guides.rubyonrails.org/command_line.html#rails-new
  2. Create Github repo (while waiting for rails to init)
    1. Add remote origin
  3. Add a landing page
    1. Controller file and action
      1. touch app/controllers/pages_controller.rb
    2. Create template
      1. mkdir app/views/pages && touch app/views/pages/index.html.erb
      2. add text
    3. Configure root route
      1. root to: 'pages#index'
  4. Create Heroku app
  5. Create Codeship project
    1. Install the github app if not added yet
      1. Follow provided link or: https://github.com/apps/cloudbees/installations/new?state=codeship
    2. Give codeship permission to read your repos
      1. Follow link or: gettings/installations -> repository access
    3. Select Basic Codeship project
  6. Set up CD pipeline on Codeship
    1. pipeline: https://docs.cloudbees.com/docs/cloudbees-codeship/latest/basic-continuous-deployment/deployment-to-heroku
  7. Set up deployment Test Setup Commands
    1. custom or dropdown
    2. Common Errors: ruby version is not on heroku, bundler version, deadlock, etc
  8. Setup Deployment steps
    1. heroku access key
  9. Add Rails configuration for RSpec
  10. (Optional) Add Rails configuration for Rubocop
  11. Set up CI pipeline on Codeship
  12. Set up test steps
  13. Add codeship badge to github repo
  14. Set up Production environment
  15. Configure production branch
  16. Create Heroku app (app-name-production)
  17. Create production CI/CD pipeline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment