Connect Heroku with GitHub using Workflow Actions

In this section we are Connecting to Heroku with GitHub using workflow actions.

We are using workflow action whenever  the heroku fails, while doing a manual method to connect to Github.

Following Steps for connecting Heroku with GitHub:

Step 1: 

Select the project repository, then we select the Actions Tab.

heroku with github

Step 2:

In the actions tab, Click the setup a workflow yourself

heroku with github

Step 3:

It creates the folder and an .yml file. In that yml file we need to write the content that connects the Heroku and the branch that deploys for that specified app.

heroku with github

Content of the yml file:

name: Deploy
      - master
    runs-on: ubuntu-latest
      - uses: actions/checkout@v2
      - uses: akhileshns/heroku-deploy@v3.12.12 # This is the action
          heroku_api_key: ${{secrets.HEROKU_API_KEY}}
          heroku_app_name: "YOUR APP's NAME" #Must be unique in Heroku
          heroku_email: "YOUR EMAIL"

Here heroku_api_key, heroku_app_name, heroku_email are the required variables. we should  avoid the hard coded values for the variables stored in Secrets.

Step 4:

Add the Variable values in Secrets:

Settings >> Secrets >> New Repository Secrets 

Adding the value for the secret by submitting name and value in the respective fields.

For getting the heroku api key:
In the Heroku app, there is an Account Settings scroll down to the page to find Heroku API key and give the reveal button to view the api key. 

heroku with github