Skip to content

Deploying Branches to Heroku [WIP]

Mike Green edited this page Feb 28, 2020 · 10 revisions

On Heroku

Create a new app

  • click new
  • select create new app
  • add your name of the app (otherwise, they will assign a random name)
  • click create app
  • upon returning to the main screen, select overview from the menu
  • click on Configure add-ons
  • on the next screen, click the search bar (it says quickly add add-ons from Elements)
  • add Heroku Postgres and Timber.io Logging
  • Back on the Dashboard screen, select Settings
    • Under Config Vars, click on Reveal Config Vars. DATABASE_URL should already have a value. Add PYTHONPATH as another key and the value should be ./cfgov
    • Under Buildpacks, click Add Buildpacks and add heroku/nodejs and heroku/python
  • Back on the Dashboard screen, select Deploy
    • Under Deploy using Heroku Git:
      • follow the instructions Install Heroku CLI only if you don't already have it installed on your computer

On Local

Branch Creation

Locally, create new branch off of staging:

git checkout staging
git checkout -b stage/my-feature 
make your code changes on this branch - is this right?
Merge your feature branch into the new `stage/my-feature` branch 
* is this the name of the feature branch?  The name of my feature branch is called 
mm/coc-alternate-workflow.  When I do this, should the command be 
git checkout -b stage/mm/coc-alternate-workflow
git checkout staging - should I check this out first
git merge my-feature

Initial Deploy

In Heroku admin, go to the Deploy tab and follow instructions for adding the app as a remote:

heroku git:remote -a cryptic-river-54210 --remote my-feature

In Heroku admin, go to Settings and make sure the buildpack order is Node, then Python.

Locally, edit your .yarnrc file and delete the line that says: --install.pure-lockfile true if it's present. You'll need to re-add it later before you deploy.

Locally, run yarn.

Locally, add the new yarn.lock file and commit.

Push your branch to Github: git push -u origin stage/my-feature

Push to Heroku to deploy: git push my-feature stage/my-feature:master

After First Deploy

After first deploy, you need to setup the initial data in the DB:

Locally, run heroku run bash -r my-feature to get an interactive shell that lets you interact with your deployed app.

Then, run ./initial-data.sh. This will create the database, setup the tables, and seed the necessary content.

When deploy succeeds and is complete, switch back to your feature branch git checkout my-feature.

Subsequent deploys

Make changes to feature branch as usual, commit, etc.

Checkout your staging branch git checkout stage/my-feature.

Merge your feature branch in git merge my-feature

Push to Github and heroku:

git push origin stage/my-feature
git push my-feature stage/my-feature
Clone this wiki locally