EndBug / add-and-commit

:octocat: Automatically commit changes made in your workflow run directly to your repo
MIT License
1.13k stars 117 forks source link

Work Failed. `Error: fatal: You are not currently on a branch.` #656

Closed Confucian-e closed 2 months ago

Confucian-e commented 2 months ago

Describe the bug I'm using that for generate CHANGELOG and commit it when I push tags. Meet Error: fatal: You are not currently on a branch.

Workflow used https://github.com/Confucian-e/hardhat-template/actions/runs/10210929795/workflow

Expected behavior It should work and commit the CHANGELOG.md which I generated in before step.

Logs https://github.com/Confucian-e/hardhat-template/actions/runs/10210929795/job/28251386119

Logs
Error: Error: 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:
EndBug commented 2 months ago

You workflow is running on tag events, so when you run actions/checkout you're not checking out a branch, and that's the reason after you make that commit you find yourself in the detached head state.

You need to either checkout out a branch on the actions/checkout step, or specify which branch you want to push to in the EndBug/add-and-commit step by using the push input.

Confucian-e commented 2 months ago

Thank you sir! I switch to run on push events and it works.