DEV Community

Cover image for How to deploy apps from GitHub to Heroku
Jeisson Florez
Jeisson Florez

Posted on • Updated on

How to deploy apps from GitHub to Heroku

Some weeks ago, the Heroku’s GitHub integration was deactivated due to an issue where some tokens of private repositories in GitHub were compromised and attackers were potentially able to download and access source code of those repositories. More info regarding the issue in a blog post from Heroku.

There are many posts, threads on Twitter and videos about alternatives to Heroku, however, for those who want to keep using it as platform provider with a similar behaviour as the official integration, there are some alternatives without put too much effort on it like using GitHub actions.

GitHub Action - Deploy to Heroku

Deploy to Heroku is a GitHub action that allow to deploy to Heroku by using NodeJS commands under the hoods. The official documentation is pretty clear and complete, so to use this action (as any other action 😛) we just need to follow some basic steps.

In this case we are going to use The Procfile | Heroku Dev Center but there are also options to application using docker configurations.

  • Make sure the folder named .github/workflows/ exists.
  • Create or modify the YAML file that contains the GitHub action we want to use to deploy.
  • Add the akhileshns/heroku-deploy@v3.12.12 to your job.
    runs-on: ubuntu-latest
      .... other steps 

      - name: Deploy to stage
        uses: akhileshns/heroku-deploy@v3.12.12
          heroku_api_key: ${{secrets.HEROKU_API_KEY}}
          heroku_app_name: ${{secrets.HEROKU_APP}}
          heroku_email: ${{secrets.HEROKU_EMAIL}}
Enter fullscreen mode Exit fullscreen mode
  • Set the environment variables in the repository using the action. Go to Settings -> Security -> Secrets -> Actions.

Add secrets to GitHub

  • Execute the job and check that it is able to finish the deployment successfully.

Job execution success

I have tried other options to make a deployment to Heroku from GitHub like using the Heroku CLI commands directly but in terms of simplicity and easiness I believe this is one of the easiest way to get close to how it was working before with the official integration.

If you like this post you can find more in and follow me in twitter @jeissonflorez29 👋

Discussion (0)