Open Kraymer opened 3 years ago
Clue:
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
I had the same issue, but my case was a different clue, and so a different fix. 😝
Yo. Now I got your same error. Add force: true
to fix this:
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}
force: true
Not sure if force pushing is going to be safe, I'm wondering if doing a git pull before you push would do the job.
Quick note in response to the force push suggestion: Don't force push unless you know what you are doing. Many, many people have shot themselves in the foot with git push -f
.
Also, as another data point, I get the same error as the OP on ad-m/github-push-action@master
but ad-m/github-push-action@v0.5.0
works fine.
And on an unrelated note, it's a really bad practice to recommend people to use ad-m/github-push-action@master
as is being done in the README. It might just introduce unexpected errors in people's workflows even though seemingly nothing changed...
It looks like you would get this error if you have no new commits to push. For example, let's say you have a workflow that triggers on a pull_request that does:
If there are no changes in the format code step, you'll get that error in the push step. So, question then. Should you commit with --allow-empty and just always create another commit or is it possible to fail gracefully if there is nothing to push?
My action :
Error log :
Note: I did not commit in the remote branch after the commit that triggered the action