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

  1. Sign up for a Heroku account if you don't already have one.

  2. Install the Heroku CLI. On macOS:

    brew tap heroku/brew && brew install heroku
    
  3. Set up an app in the main project dir:

    npm run heroku:setup
    

    You 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.

  1. Create a Heroku API token:

    heroku authorizations:create -d "GitHub Actions"
    

    Copy the "Token" value.

  2. Add the following GitHub repository secrets:

    • HEROKU_API_KEY: the Heorku authorization token
    • HEROKU_APP_NAME: the Heroku app name (heroku apps if you forgot it)

From now on, whenever you push or merge into the main branch, GitHub will automatically deploy the branch to Heroku! ๐Ÿ™Œ

Tips

TaskCommand
Access your appheroku open
See the running app logheroku logs -t
See details about your appheroku apps:info
Rename your appheroku apps:rename <NEWNAME>
Access the app dashboardnpm run heroku:dashboard
Access the Heroku PostgreSQL instancenpm run heroku:psql
See the database connection stringheroku config:get DATABASE_URL
Access the database dashboardheroku addons:open DATABASE

Additional Information