Once you're at a reasonable break-point with your work so far. I'd like this done by 5pm at the latest.
Deploying means publishing. You've been hosting locally up until now. Deploying means publishing your code somewhere that is not local, so that the world can access it.
What's not local can be considered remote. So GitHub, for example, is a remote storage of your repo. To push to a remote using Git, you type git push [name of remote] [name of branch–like git push origin master (Because GitHub is called "origin", and you're pushing your master branch). Or git push origin 4-my-new-feature, if you're pushing some feature branch.
To deploy your code, you'll be pushing to a new remote, called Heroku. Like GitHub, Heroku is a remote storage of your repo, but it also publishes that code by running rackup for you and allocating a URL like http://elegant-bobcat-23483.herokuapp.com for your project alone. Since it does that, it doesn't do other things, like allow for conversations or otherwise facilitate collaboration.
Set Up Heroku
Create the Heroku Remote
One person should do the following:
[ ] On iTerm, from your project folder (any branch), run heroku create.
The output will be something like:
Creating app... done, stack is cedar-14
https://sleepy-ocean-52379.herokuapp.com/ | https://git.heroku.com/sleepy-ocean-52379.git
The first URL there is your project's dedicated URL! The second one (ending in .git is the location of the Heroku remote repo storage).
Setting Up the Heroku "Remote"
Running heroku create automatically added that repo storage to your computer as a "remote". So now, just like you can do git push origin master to push to GitHub, you can also do git push heroku master to push to Heroku. GitHub and Heroku are not connected in any way–you have to push to each manually.
Your computer has the Heroku remote, but your partner's does not. Your partner doesn't need to create a new Heroku app, though. They just need to add a connection to the Heroku remote:
[ ] Have your partner do git remote add heroku https://git.heroku.com/sleepy-ocean-52379.git (Replace the URL here with your actual Heroku repo's location.)
Now your partner will be able to git push heroku master from their computer also.
Permissions
You need to give your partner, Alex, and Sumeet permission to access the Heroku remote. Otherwise, even though we can add the remote to our computers, we'll get rejected if we try to push to it.
The person who created the remote in the first place should do the following:
[ ] From your Heroku dashboard, click on the name of your newly created application.
For that project, click the 'Access' tab and add the following collaborators:
[ ] Your partner, using their email address (The same email they used to sign up for Heroku back in the day)
[ ] sumeet@sumeetjain.com
[ ] alexandrajmh@gmail.com
Now everyone can deploy, if needed.
Database
When you deploy, your code is pushed but not your database. That's a good thing–it means you can add silly information for testing your project that no one else will see. But we do need to create a fresh database on Heroku for our deployed application to use.
One person in the pair should do this in iTerm, from the project folder:
[ ] heroku addons:create heroku-postgresql
The output should be something like this:
Creating postgresql-opaque-94052... done, (free)
Adding postgresql-opaque-94052 to sleepy-ocean-52379... done
Setting DATABASE_URL and restarting sleepy-ocean-52379... done, v3
Database has been created and is available
! This database is empty. If upgrading, you can transfer
! data from another database with pg:copy
Use `heroku addons:docs heroku-postgresql` to view documentation.
Now everyone can deploy, and the Heroku remote has a database for the application to use.
Before you deploy, there are some things to do.
You will only ever deploy the 'master' branch.
Let's deploy your 'master' branch, as it is currently–it's okay if there's not much/anything on it yet. You can continue working on your feature branch after you've deployed 'master'. (Then when it's ready, you can merge it into 'master' and re-deploy!)
One person should do the following:
[ ] If you're on a feature branch, do git status
[ ] If that indicates there are any modifications yet to be staged/committed, do a full git add/commit/push process to get the current state of the feature branch saved.
Don't move ahead if git status continues to show a non-clean status.
[ ] Switch to the 'master' branch (git checkout master)
[ ] On the 'master' branch, git pull - just to make sure everything from GitHub that's been merged to 'master' is up to date.
Fix Sumeet's Bug
Now you have to fix a bug that Sumeet accidentally introduced in the project's starter code. :sob:
You can make this change directly on the 'master' branch–it's okay this one time.
Open the file in your project called Gemfile and make this change:
[ ] gem "dotenv", :groups => [:development, :test] should be gem "dotenv"
[ ] After saving that file, run bundle install in iTerm.
[ ] Run git status.
There should only be two files with changes - Gemfile and Gemfile.lock. If that's correct, then:
Once you're at a reasonable break-point with your work so far. I'd like this done by 5pm at the latest.
Deploying means publishing. You've been hosting locally up until now. Deploying means publishing your code somewhere that is not local, so that the world can access it.
What's not local can be considered remote. So GitHub, for example, is a remote storage of your repo. To push to a remote using Git, you type
git push [name of remote] [name of branch
–likegit push origin master
(Because GitHub is called "origin", and you're pushing your master branch). Orgit push origin 4-my-new-feature
, if you're pushing some feature branch.To deploy your code, you'll be pushing to a new remote, called Heroku. Like GitHub, Heroku is a remote storage of your repo, but it also publishes that code by running
rackup
for you and allocating a URL like http://elegant-bobcat-23483.herokuapp.com for your project alone. Since it does that, it doesn't do other things, like allow for conversations or otherwise facilitate collaboration.Set Up Heroku
Create the Heroku Remote
One person should do the following:
heroku create
.The output will be something like:
The first URL there is your project's dedicated URL! The second one (ending in
.git
is the location of the Heroku remote repo storage).Setting Up the Heroku "Remote"
Running
heroku create
automatically added that repo storage to your computer as a "remote". So now, just like you can dogit push origin master
to push to GitHub, you can also dogit push heroku master
to push to Heroku. GitHub and Heroku are not connected in any way–you have to push to each manually.Your computer has the Heroku remote, but your partner's does not. Your partner doesn't need to create a new Heroku app, though. They just need to add a connection to the Heroku remote:
git remote add heroku https://git.heroku.com/sleepy-ocean-52379.git
(Replace the URL here with your actual Heroku repo's location.)Now your partner will be able to
git push heroku master
from their computer also.Permissions
You need to give your partner, Alex, and Sumeet permission to access the Heroku remote. Otherwise, even though we can add the remote to our computers, we'll get rejected if we try to push to it.
The person who created the remote in the first place should do the following:
Now everyone can deploy, if needed.
Database
When you deploy, your code is pushed but not your database. That's a good thing–it means you can add silly information for testing your project that no one else will see. But we do need to create a fresh database on Heroku for our deployed application to use.
One person in the pair should do this in iTerm, from the project folder:
heroku addons:create heroku-postgresql
The output should be something like this:
Now everyone can deploy, and the Heroku remote has a database for the application to use.
Before you deploy, there are some things to do.
You will only ever deploy the 'master' branch.
Let's deploy your 'master' branch, as it is currently–it's okay if there's not much/anything on it yet. You can continue working on your feature branch after you've deployed 'master'. (Then when it's ready, you can merge it into 'master' and re-deploy!)
One person should do the following:
git status
git add/commit/push
process to get the current state of the feature branch saved.git status
continues to show a non-clean status.git checkout master
)git pull
- just to make sure everything from GitHub that's been merged to 'master' is up to date.Fix Sumeet's Bug
Now you have to fix a bug that Sumeet accidentally introduced in the project's starter code. :sob:
You can make this change directly on the 'master' branch–it's okay this one time.
Open the file in your project called Gemfile and make this change:
gem "dotenv", :groups => [:development, :test]
should begem "dotenv"
bundle install
in iTerm.git status
.git add .
,git commit -m "Fix Sumeet's bug."
,git push
Now you're ready to deploy.
Whoever fixed Sumeet's bug should do this from the 'master' branch:
git push heroku master
Watch as Heroku detects the Ruby app in your code, does its own
bin/setup
stuff, and eventually says "Launched".Go to the URL of your website to see it in action! (It's okay if you haven't built much functionality yet, but whatever you have built should work.)
Future Deploys
When deploying in the future, just make sure you're on the 'master' branch and
git push heroku master
.You'll never deploy anything but the 'master' branch, and you'll never
git pull
from Heroku. You'll only ever push 'master'.