stefanzweifel / git-auto-commit-action

Automatically commit and push changed files back to GitHub with this GitHub Action for the 80% use case.
MIT License
1.97k stars 226 forks source link

You're not currently on a branch #201

Closed yves-chevallier closed 2 years ago

yves-chevallier commented 2 years ago

Version of the Action v4.x.x

Describe the bug When pushing a new tag, the action seem to checkout the master, but on a detached head

Started: bash /home/runner/work/_actions/stefanzweifel/git-auto-commit-action/v4/entrypoint.sh
INPUT_REPOSITORY value: .
INPUT_STATUS_OPTIONS: 
INPUT_BRANCH value: 
From https://github.com/heig-tin-info/refcard-python
 * [new branch]      master     -> origin/master
M   preview.png
INPUT_ADD_OPTIONS: 
INPUT_FILE_PATTERN: .
INPUT_COMMIT_OPTIONS: 
INPUT_COMMIT_USER_NAME: GitHub Actions
INPUT_COMMIT_USER_EMAIL: actions@github.com
INPUT_COMMIT_MESSAGE: Update preview
INPUT_COMMIT_AUTHOR: yves-chevallier <yves-chevallier@users.noreply.github.com>
[detached HEAD 16b7f81] Update preview
 Author: yves-chevallier <yves-chevallier@users.noreply.github.com>
 1 file changed, 0 insertions(+), 0 deletions(-)
 rewrite preview.png (94%)
INPUT_TAGGING_MESSAGE: 
No tagging message supplied. No tag will be added.
INPUT_PUSH_OPTIONS: 
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: Invalid status code: 128
    at ChildProcess.<anonymous> (/home/runner/work/_actions/stefanzweifel/git-auto-commit-action/v4/index.js:17:19)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
  code: 128
}
Error: Invalid status code: 128
    at ChildProcess.<anonymous> (/home/runner/work/_actions/stefanzweifel/git-auto-commit-action/v4/index.js:17:19)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)

Here the issue in context: https://github.com/heig-tin-info/refcard-python/runs/4983653913?check_suite_focus=true

What would be the issue and how should I solve it?

yves-chevallier commented 2 years ago

Can be solved by forcing the branch

      - name: Checkout code
        uses: actions/checkout@v2
        with:
          ref: master
          fetch-depth: 0 # To get all tags