Deploy to Heroku
-
Go to the Heroku website, if you don’t have a account, register one first.
-
Open Command Line, enter
heroku login
, hit any button, when you seeheroku: Press any key to open up the browser to login or q to exit:
, it will jump to the webpage where it ask us toLog in
Heroku. -
You may have to manually enter your username and password for Heroku in your command line if browser in your command line browser window does not open.
- Create a Heroku Project Command:
heroku create spending-log --buildpack mars/create-react-app
.- This create-react-app-buildpack is also great because it will also use the production build of our react-app for the deployment.
- Here is the buildpacks command:
COMMANDS buildpacks:add add new app buildpack, inserting into list of buildpacks if necessary buildpacks:clear clear all buildpacks set on the app buildpacks:info fetch info about a buildpack buildpacks:remove remove a buildpack set on the app buildpacks:search search for buildpacks buildpacks:set buildpacks:versions list versions of a buildpack
git add .
git commit -m "fix all the problem"
git push heroku master
Deploy to Github
- Run
yarn build
to build the project, you will get a build folder, this is for displaying the content in a independent website. - Check current project the
.gitignore
file, to make sure we exclude thebuild
folder - Run
yarn global add serve
- Run
serve -s build
You will learn more about deployment from this webpage: Deployment - Create a new repository in github to store the production of this project.
- Go to build folder
- Run
git init
- Run
git add .
- Run
git commit -m "deploy spending log project to github"
- Run
git remote add origin git@github.com:Yueran-Yu/spending-log-app.git
- Run
git push --set-upstream origin master
- Go to
package.json
, add"homepage" : "."
package.json at the top.
The custom deploy script: deploy.sh
- create a file deploy.sh under the folder scripts
- Add the bash shebang #!/usr/bin/env bash
#!/usr/bin/env bash
yarn build &&
cd build &&
git init &&
git add . &&
git commit -m 'deploy' &&
git remote add origin git@github.com/ &&
git push -u origin master -f &&
cd -
- These are the executable script example in the
deploy.sh
file. - Final step: add
"deploy: "sh scripts/deploy.sh
to thepackage.json
file. - Run
yarn deploy
, it will automatically deploy the script as you provided.