You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to create a workflow that would come into each PR and format the code according to the code style. On paper, it looks simple: pull PR, run formatting, push any changes.
My workflow:
on: [push, pull_request]jobs:
format:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm run format --if-present
- run: | git config user.name github-actions git config user.email github-actions@github.com git add --all git diff-index --quiet HEAD || git commit -m "style: format code" git push
And it works great for push events. However, I get an error in pull_request events:
[detached HEAD 36717a0] style: format code
1 file changed, 1 insertion(+), 1 deletion(-)
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>
Error: Process completed with exit code 128.
I don't understand what caused this error, and how should I initialize the workflow to be able to push changes back to PR
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I would like to create a workflow that would come into each PR and format the code according to the code style. On paper, it looks simple: pull PR, run formatting, push any changes.
My workflow:
And it works great for
push
events. However, I get an error inpull_request
events:I don't understand what caused this error, and how should I initialize the workflow to be able to push changes back to PR
Beta Was this translation helpful? Give feedback.
All reactions