Deployment
April 21, 2021 ยท View on GitHub
This project is set up to deploy to Heroku, using the Container stack.
Prerequisites
Read the README
The [prerequisites to deploy to Heorku][prerequisites] is the same as the local development environment.
You'll also need to [setup up the .env file][dotenv] in your project
directory.
Setup
-
Sign up for a Heroku account if you don't already have one.
-
Install the Heroku CLI. On macOS:
brew tap heroku/brew && brew install heroku -
Set up an app in the main project dir:
npm run heroku:setupYou may be asked to login so the Heroku CLI can perform tasks in your account.
At the end of the process (which will take about 5 minutes), you'll be shown the details of your app, including the URL of where you can access the app.
You should see the app running in your browser. If not, just visit the URL.
Deployment
As you make code changes to the server or the app, you can always deploy your current working branch to see it running at Heroku:
npm run heroku:deploy
Automatic Deployment
This repo also contains a GitHub Actions deployment workflow. Any new
commits to the main branch will trigger the workflow.
โ ๏ธ IMPORTANT: You still need to run the Heroku setup step before you can automatically deploy.
-
Create a Heroku API token:
heroku authorizations:create -d "GitHub Actions"Copy the "Token" value.
-
Add the following GitHub repository secrets:
HEROKU_API_KEY: the Heorku authorization tokenHEROKU_APP_NAME: the Heroku app name (heroku appsif you forgot it)
From now on, whenever you push or merge into the main branch, GitHub will
automatically deploy the branch to Heroku! ๐
Tips
| Task | Command |
|---|---|
| Access your app | heroku open |
| See the running app log | heroku logs -t |
| See details about your app | heroku apps:info |
| Rename your app | heroku apps:rename <NEWNAME> |
| Access the app dashboard | npm run heroku:dashboard |
| Access the Heroku PostgreSQL instance | npm run heroku:psql |
| See the database connection string | heroku config:get DATABASE_URL |
| Access the database dashboard | heroku addons:open DATABASE |