# Deploy to heroku

## Install Heroku CLI

If you haven't already, install the CLI: <https://devcenter.heroku.com/articles/heroku-cli>

## 1. Connect a heroku app

### New app

Create your app manually at dashboard.heroku.com or type:

```
heroku create your-app
```

### Existing app

If you've already created your app, connect it:

```
heroku git:remote -a your-app
```

## 2. Adding Node.js and .NET Core buildbacks

.NET Core is not officially supported on Heroku at present. Third party buildpacks are one option for extending the platform, for this project we are using: <https://elements.heroku.com/buildpacks/jincod/dotnetcore-buildpack>

```
heroku buildpacks:add heroku/nodejs
heroku buildpacks:add jincod/dotnetcore
```

### Heroku environment variables

```
heroku config:set ASPNETCORE_ENVIRONMENT=Production
```

You can change environment variables directly from the heroku app settings:

![](https://1528942926-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MEse5A9Po6xt6ZmrGcz%2F-MFTl4VfDCx9Xw5JSROY%2F-MFUG7LH0XMWWZ3oFNc4%2FScreen%20Shot%202020-08-24%20at%202.00.14.png?alt=media\&token=085a2312-29dc-4b5c-80d7-82dee8d4e837)

## 3. Deploy

You can directly push to the heroku repository:

```
git push heroku master
```

![Herokuapp deployed](https://1528942926-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MEse5A9Po6xt6ZmrGcz%2F-MFTl4VfDCx9Xw5JSROY%2F-MFUIld5wkZRPPxyWO_j%2FScreen%20Shot%202020-08-24%20at%202.11.45.png?alt=media\&token=c7babce3-66e3-4a2d-86d3-705038831023)

Or better yet, go to [https://dashboard.heroku.com/apps/**YOUR-APP**/deploy/github](https://dashboard.heroku.com/apps/YOUR-APP/deploy/github) and enable **Automatic deploys** so you only deploy when you type:

```
git push origin master
```

### 4. Open your app

Open your app yourappname.herokuapp.com and ensure everything is working.

{% hint style="warning" %}
If you set your LIVE Stripe API Keys and LIVE products, keep in mind that you will be charged.
{% endhint %}
