How to deploy apps from GitHub to Heroku πŸš€πŸš€

12 May 2022 / 2 min read

How to deploy apps from GitHub to Heroku

Some weeks ago, the Heroku’s GitHub integration was deactivated due to a security issue where some OAuth user tokens for third-party integrations in GitHub were compromised and attackers were potentially able to download and access source code of 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.

  1. Make sure the folder named .github/workflows/ exists.
  2. Create or modify the YAML file that contains the GitHub action we want to use to deploy.
  3. 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}}
  1. Set the environment variables in the repository using the action. Go to Settings -> Security -> Secrets -> Actions.
  1. Execute the job and check that it is able to finish the deployment successfully.


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.