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

Style (pull_request) always fails on Git detached HEAD error #683

Closed
nanxstats opened this issue Jan 9, 2023 · 3 comments · Fixed by #691
Closed

Style (pull_request) always fails on Git detached HEAD error #683

nanxstats opened this issue Jan 9, 2023 · 3 comments · Fixed by #691
Labels
bug an unexpected problem or unintended behavior

Comments

@nanxstats
Copy link

Describe the bug
When creating a pull request, two workflow runs will be created for the {styler} workflow. The Style (push) run is successful but Style (pull_request) always fails at the "Commit and push changes" step on a Git detached HEAD error.

To Reproduce
Example pull request: https://github.com/nanxstats/stylertest/pull/1
Full log for failed run: https://github.com/nanxstats/stylertest/actions/runs/3875928032/jobs/6609199407

Expected behavior
Both runs of the workflow should be successful.

Additional context
The error message often looks like this:

Run git config --local user.name "$GITHUB_ACTOR"
HEAD detached at pull/1/merge
nothing to commit, working tree clean
No changes to commit
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

Error: Process completed with exit code 1.
@nanxstats nanxstats added the bug an unexpected problem or unintended behavior label Jan 9, 2023
@dpprdan
Copy link
Contributor

dpprdan commented Jan 14, 2023

Confirmed and I see the same on the document (pull_request) workflow.

Are the on: pull_request workflows even necessary, with on: push in place without a branch filter? I.e. the latter are executed on all branches anyway (also on forked repos), including PR branches?! 🤔

@arisp99 (who authored the workflows) any idea, what's going on here?

@arisp99
Copy link
Contributor

arisp99 commented Jan 16, 2023

Based on actions/checkout#124, it seems that when the code is checked out during the pull_request trigger, the code is checked out in the detached HEAD state, so we can't pull and push to the branch. This doesn't happen for the push trigger. It is possible to work around this, but @dpprdan is correct that the push trigger also catches pull requests so the easiest solution would likely be to remove the pull_request trigger.

@github-actions
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue and include a link to this issue

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants