Skip to content

Pushing New Versions To Heroku

Dan Avery edited this page Nov 4, 2013 · 4 revisions

To The Trails: Deploying the Production App

To deploy an updated version of To The Trails:

This document is intended to be a quick guide to pushing out revised versions of To The Trails to the Heroku app hosting service. This does not include directions for updating the Github repositories with revised code. The assumption in this document is that the Github repository has already been updated with new code and the application now needs to be re-deployed to the Heroku servers.

Getting and Updating the Code

Make sure you have the Git version control system installed and available from a command line. We don't have any experience with the Windows version, but steps and results should be the same as with the OS X and Linux versions.

First Time

The first thing you'll need to do is to clone the existing Github back-end repository:

git clone git@github.com:codeforamerica/trailsyserver.git trailsyserver

Then get the "trailsy" front-end repository as a submodule:

git submodule init
git submodule update

(Note that the Git URL may change if local developers make their own copy of the repository to work from. They may give you a different but very similar-looking URL to use instead of the one above.)

This will copy the repository to your local machine to a directory called "trailsyserver". The Trailsy front-end repository will be copied to the "public" directory of trailsyserver--Trailsy is a git subtree of trailsyserver, so both repositories are copied with the above cloning command.

Updating

After getting your clone, to get future updates, you can run

git pull

in the trailsyserver directory, and any changes to the trailsyserver backend will get merged into your copy. You don't need to re-clone the repository as above unless you've deleted it locally in the meantime.

Because the "trailsy" front-end git repository is included in the backend "trailsyserver" repository as a git "submodule", there are couple more steps required to obtain updated front-end code.

First, move to the "public" directory of trailsyserver. Then:

git checkout master
git pull
cd ..
git add .
git commit -m "Updating trailsy submodule"
git push

Git submodules add some complexity. The advantage is that we can effectively embed one repository inside another and avoid the need for two Heroku applications (and bills). The disadvantage is the added complexity of updates. One possible future avenue of simplification here might be to include trailsy as a "subtree" of trailsyserver, not a submodule.

Deploying the App to Heroku

To set up your repository to push to Heroku:

You'll need to set up your SSH keys with Heroku before you can send anything to Heroku's servers. See "Managing Your SSH Keys" for details from Heroku.

git remote add heroku git@heroku.com:trailsy.git

(Note that if you're pushing to a different Heroku application instance than the To The Trails production app, you'll change the "trailsy" part of the above URL to the name of your Heroku app.)

You'll only need to do this once as well, unless you delete the local repository. This will set up Heroku as a git "remote" to which you can push copies of the repository.

Once you have the latest changes pulled locally, you can run

git push heroku master

This will sync the master branch of your local Git To The Trails repository to the master branch of the remote Heroku server. Once the sync is finished, Heroku will automatically deploy the version you've just pushed.