title: Why can't I deploy to Heroku in GitHub Action: `Command failed: git push heroku HEAD:refs/heads/main --force`?
body: <p>I am trying to learn deployment in GitHub Action. In my <code>.github/workflows/demo.yml</code> file in my repository in GitHub, I added the following job for deployment to Heroku, by copying and modifying from <a href="https://github.com/marketplace/actions/deploy-to-heroku" rel="nofollow noreferrer">https://github.com/marketplace/actions/deploy-to-heroku</a>:</p>
  <pre><code>  Deploy-to-Heroku:
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v2
        # install Heroku: https://github.com/marketplace/actions/deploy-to-heroku
        - uses: akhileshns/heroku-deploy@v3.12.12 # This is the action
          with:
            # first in Heroku online account: account -&gt; Account Settings -&gt; API Key. copy it.
            # then in your project's repository on GitHub, Settings -&gt; Secrets -&gt; actions -&gt; New repository secret: Then enter HEROKU_API_KEY as the name and paste the copied API Key as the value.
            heroku_api_key: ${{secrets.HEROKU_API_KEY}}
            heroku_app_name: &quot;test-github-action-123abc&quot; #Must be unique in Heroku. letters must be lower case, not upper case. c.f. error output
            heroku_email: &quot;xxxx@xxxx.com&quot;
  </code></pre>
  <p>I was wondering why the deployment fails:</p>
  <pre><code>Run akhileshns/heroku-deploy@v3.12.12
  From https://github.com/xxx/testGithubAction
   * [new branch]      xxx-patch-1 -&gt; origin/xxx-patch-1
  Created and wrote to ~/.netrc
  Successfully logged into heroku
   ›   Warning: Our terms of service have changed: 
  Added git remote heroku
   ›   https://dashboard.heroku.com/terms-of-service
  remote: Compressing source files... done.        
  remote: Building source:        
  remote: 
  remote: -----&gt; Building on the Heroku-20 stack        
  remote: -----&gt; Determining which buildpack to use for this app        
  remote:  !     No default language could be detected for this app.        
  remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.        
  remote: See https://devcenter.heroku.com/articles/buildpacks
  remote: 
  remote:  !     Push failed        
  remote: Verifying deploy...        
  remote: 
  remote: !Push rejected to test-github-action-123abc.        
  remote: 
  To https://git.heroku.com/test-github-action-123abc.git
   ! [remote rejected] HEAD -&gt; main (pre-receive hook declined)
  error: failed to push some refs to 'https://git.heroku.com/test-github-action-123abc.git'
      Unable to push branch because the branch is behind the deployed branch. Using --force to deploy branch. 
      (If you want to avoid this, set dontuseforce to 1 in with: of .github/workflows/action.yml. 
      Specifically, the error was: Error: Command failed: git push heroku HEAD:refs/heads/main 
  remote: Compressing source files... done.        
  remote: Building source:        
  remote: 
  remote: -----&gt; Building on the Heroku-20 stack        
  remote: -----&gt; Determining which buildpack to use for this app        
  remote:  !     No default language could be detected for this app.        
  remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.        
  remote: See https://devcenter.heroku.com/articles/buildpacks
  remote: 
  remote:  !     Push failed        
  remote: Verifying deploy...        
  remote: 
  remote: !Push rejected to test-github-action-123abc.        
  remote: 
  To https://git.heroku.com/test-github-action-123abc.git
   ! [remote rejected] HEAD -&gt; main (pre-receive hook declined)
  error: failed to push some refs to 'https://git.heroku.com/test-github-action-123abc.git'
  remote: Compressing source files... done.        
  remote: Building source:        
  remote: 
  remote: -----&gt; Building on the Heroku-20 stack        
  remote: -----&gt; Determining which buildpack to use for this app        
  remote:  !     No default language could be detected for this app.        
  remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.        
  remote: See https://devcenter.heroku.com/articles/buildpacks
  remote: 
  remote:  !     Push failed        
  remote:  !        
  remote:  ! ## Warning - The same version of this code has already been built: 235b1971a13f659e7a3572c11caf9a1e4c2abce4        
  remote:  !        
  remote:  ! We have detected that you have triggered a build from source code with version 235b1971a13f659e7a3572c11caf9a1e4c2abce4        
  remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.        
  remote:  !        
  remote:  ! If you are developing on a branch and deploying via git you must run:        
  remote:  !        
  remote:  !     git push heroku &lt;branchname&gt;:main        
  remote:  !        
  remote:  ! This article goes into details on the behavior:        
  remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
  remote: 
  remote: Verifying deploy...        
  remote: 
  remote: !Push rejected to test-github-action-123abc.        
  remote: 
  To https://git.heroku.com/test-github-action-123abc.git
   ! [remote rejected] HEAD -&gt; main (pre-receive hook declined)
  error: failed to push some refs to 'https://git.heroku.com/test-github-action-123abc.git'
  Error: Error: Command failed: git push heroku HEAD:refs/heads/main --force
  remote: Compressing source files... done.        
  remote: Building source:        
  remote: 
  remote: -----&gt; Building on the Heroku-20 stack        
  remote: -----&gt; Determining which buildpack to use for this app        
  remote:  !     No default language could be detected for this app.        
  remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.        
  remote: See https://devcenter.heroku.com/articles/buildpacks
  remote: 
  remote:  !     Push failed        
  remote:  !        
  remote:  ! ## Warning - The same version of this code has already been built: 235b1971a13f659e7a3572c11caf9a1e4c2abce4        
  remote:  !        
  remote:  ! We have detected that you have triggered a build from source code with version 235b1971a13f659e7a3572c11caf9a1e4c2abce4        
  remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.        
  remote:  !        
  remote:  ! If you are developing on a branch and deploying via git you must run:        
  remote:  !        
  remote:  !     git push heroku &lt;branchname&gt;:main        
  remote:  !        
  remote:  ! This article goes into details on the behavior:        
  remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
  remote: 
  remote: Verifying deploy...        
  remote: 
  remote: !Push rejected to test-github-action-123abc.        
  remote: 
  To https://git.heroku.com/test-github-action-123abc.git
   ! [remote rejected] HEAD -&gt; main (pre-receive hook declined)
  error: failed to push some refs to 'https://git.heroku.com/test-github-action-123abc.git'
  </code></pre>
  <p>Not sure if related, according to <a href="https://github.com/marketplace/actions/deploy-to-heroku" rel="nofollow noreferrer">https://github.com/marketplace/actions/deploy-to-heroku</a>:</p>
  <blockquote>
  <p>To get started using the action, just make sure to have a Procfile or a Dockerfile in your project</p>
  </blockquote>
  <p>I haven't understood Procfile, so haven't do anything about it. In particular, I don't know how to write Procfile for Python. My code in my repository is a simple Python scrypt with a test function:</p>
  <pre><code>#! /usr/env/bin python
  
  # content of test_sample.py
  def inc(x):
  return x + 1
  
  
  def test_answer():
  assert inc(3) == 4
  </code></pre>
  <p>Thanks.</p>