Heroku : Deployment

Deployment

There are many ways to deploy an app. You can use the command line and deploy using Git, or you can set up Pipelines to group stages of deployment, combined with Review Apps, which let you automatically deploy on a Pull Request. Finally, you can also deploy using a Heroku Button

Replace myapp with the name of your app.

Git

  • Deploying with Git
  • Git Cloning Existing Heroku Applications

Deploying with Git

Git is a powerful decentralized revision control system, and is the means for deploying apps to Heroku. You don’t need to be proficient with Git to use it for deploying code to Heroku, but you may find it valuable to learn the basics.

Heroku apps expect the app directory structure at the root of the repository. If your app is inside a subdirectory in your repository, it won’t run when pushed to Heroku.

Before you can push an app to Heroku, you’ll need to initialize a local Git repository and commit your files to it. For example, if you have an app in a directory, myapp, then create a new repository for it:

$ cd myapp
$ git init
Initialized empty Git repository in .git/
$ git add .(Add all file and Folder)
$ git commit -m "my first commit/Write Comment"

Your Heroku app starts with a blank repository – it has no branches and no code. So the first time you deploy, you’ll need to specify a remote branch to push to. You can do your first push:

The -f (force flag) is recommended in order to avoid conflicts with other developers’ pushes. Since you are not using Git for your revision control, but as a transport only, using the force flag is a reasonable practice.

Each time you wish to deploy to Heroku:

$ git add -A
$ git commit -m "commit for deploy to heroku"
$ git push -f heroku

Git Cloning Existing Heroku Applications

To clone the source of an existing application from Heroku using Git, use the heroku git:clone command:

$ heroku git:clone -a myapp

This will create a new directory named after your app with its source and complete repository history, as well as adding a heroku git remote to facilitate further updates.


Pipelines

A pipeline is a group of Heroku apps that share the same codebase. Each app in a pipeline represents one of the following steps in a continuous delivery workflow:

  • Review
  • Development
  • Staging
  • Production

A common Heroku continuous delivery workflow has the following steps:

  1. A developer creates a pull request to make a change to the codebase.
  2. Heroku automatically creates a review app for the pull request, allowing developers to test the change.
  3. When the change is ready, it’s merged into the codebase’s master branch.
  4. The master branch is automatically deployed to staging for further testing.
  5. When it’s ready, the staging app is promoted to production, where the change is available to end users of the app.

Example pipeline

Pipelines only manage the application slug. The Git repo, config vars, add-ons and other environmental dependencies are not considered part of a pipeline and must be managed independently. You can use Heroku Fork to quickly clone production apps to be used for dev and staging and Review apps to create temporary apps for every pull request.

Creating pipelines

To create a new pipeline, click the + icon in the top right of your app list and select “Create new pipeline”, or navigate to an app’s deploy tab and create a new pipeline to include that app.

Create pipeline from app list

Create pipeline from app

Promoting

When a change has been tested sufficiently in a particular stage, the slug can be promoted to the downstream stage using the Promote button. If there are multiple apps in the downstream stage, the slug will be promoted to all apps by default. Don’t worry, you’ll get a chance to see what you’re promoting and where it’s going before you commit.

Automatic deploys

When you enable automatic deploys for a GitHub branch, Heroku builds and deploys all pushes to that branch. If, for example, you have a development app on Heroku, you can configure pushes to your GitHub development branch to be automatically built and deployed to that app.

Automatic deploys

Other deployment types

Creating a 'Deploy to Heroku' Button

The ‘Deploy to Heroku’ button enables users to deploy apps to Heroku without leaving the web browser, and with little or no configuration. The button is ideal for customers, open-source project maintainers or add-on providers who wish to provide their customers with a quick and easy way to deploy and configure a Heroku app.

The button is well-suited for use in README files, and is intended to serve as a replacement to a list of manual steps typically required to configure an app.

Here’s an example button that deploys a sample Node.js app to Heroku:

Deploy

This document describes the requirements for apps that use the 'Deploy to Heroku’ service, and how to use these buttons make it easy to deploy source code you maintain to Heroku.

Heroku Button will not work with repos that have Git submodules. Heroku Button relies on the Build API and uses tarballs fetched from GitHub. GitHub does not include submodule contents when repo-content tarballs are generated.


Happy Sharing...


Comments

Popular posts from this blog

Salesforce LWC : Compact Layout on Hover

Salesforce LWC With Third Party JS : D3

Communications between Lightning Components : Salesforce