Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to commit to repo #21

Closed
matshou opened this issue Feb 12, 2021 · 9 comments
Closed

Failed to commit to repo #21

matshou opened this issue Feb 12, 2021 · 9 comments

Comments

@matshou
Copy link

matshou commented Feb 12, 2021

Workflow action fails after making a commit.

Link to failed action log:
https://github.com/yooksi/github-stats/runs/1885488408?check_suite_focus=true#step:7:1

 [master 2e497c2] Update generated files
 2 files changed, 33 insertions(+), 51 deletions(-)
To https://github.com/yooksi/github-stats
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/yooksi/github-stats'
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.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Error: Process completed with exit code 1.
@matshou
Copy link
Author

matshou commented Feb 12, 2021

I was able to resolve this by making the workflow pull before making a commit:
https://github.com/yooksi/github-stats/commit/b394a5d2950f88f17e58d4293e5100cf1bc71bae

The resulting action run seems to pass:
https://github.com/yooksi/github-stats/actions/runs/560328904

@jstrieb
Copy link
Owner

jstrieb commented Feb 12, 2021

Hi, thanks for reporting this! This issue is rather odd. Is it possible that you committed to the repo (or pushed a commit) while the action was running? That is the only thing I can think of that would cause this problem.

If not, I will do my best to replicate the issue, and we can go from there.

@matshou
Copy link
Author

matshou commented Feb 12, 2021

Is it possible that you committed to the repo (or pushed a commit) while the action was running?

Perhaps, I don't know. But I've tried re-running the action several times without pushing, would that inital bad push become a persistent problem for any and all runs on future commits?

@jstrieb
Copy link
Owner

jstrieb commented Feb 12, 2021

Short answer: it shouldn't cause any long-term problems with the Action.

Long answer: at a high level, here is how the Actions workflow works:

  1. It pulls the latest code from the repo
  2. Then it runs the code, which changes some of the files in the repo.
  3. Finally, it saves those changed files by committing to the repo

If you pushed code after step 1 but before step 3, then when it goes to do step 3, it sees that there is updated code it doesn't have. When this happens, it requires human intervention for a manual git merge because git doesn't know whether to keep the recently generated files, or the ones on the server it didn't know about until just now. Under normal circumstances, doing a git merge to fix this is no problem, but in this case, since it's running inside a program with no human to intervene, it just fails.

The reason it's not a long-term problem is because when it fails, it deletes the generated files from step 2 without saving them (because step 3 didn't complete). And then when it runs again, step 1 pulls down the code all fresh and new, without any conflicts.

For now, I'm assuming that is what happened. If the Action can be triggered manually just fine and runs normally at its scheduled times, then I'd say you have nothing to worry about.

Was this a one-off occurrence, or something that happened every time you ran the workflow?

@matshou
Copy link
Author

matshou commented Feb 12, 2021

This is how I assumed it worked, no idea why this is happening 🤔

I've run the linked failed run again and it still fails:
https://github.com/yooksi/github-stats/runs/1885686522

@jstrieb
Copy link
Owner

jstrieb commented Feb 12, 2021

That is...unexpected, and definitely perplexing. Thanks for confirming that it's still a problem.

Though I am glad to know adding git pull fixes the issue based on your code above, I'd like to get to the bottom of this before I apply the patch in order to make sure it's not a broader problem that will pop up again later on. I'll do my best to replicate the issue locally. In the meantime, I would be grateful for any other leads you could provide.

@jstrieb
Copy link
Owner

jstrieb commented Mar 26, 2021

@yooksi Hi, hope all is well! I've tried a bunch to replicate this, but can't seem to cause the same problem. Have there been any developments on your end?

@matshou
Copy link
Author

matshou commented Mar 27, 2021

I've setup this project again in a new repository and tried to replicate the problem without success.
Perhaps we should close this issue for now and re-open it later if the problem reoccurs.

@jstrieb
Copy link
Owner

jstrieb commented Mar 28, 2021

Will do. Thanks for the reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants