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.98k stars 227 forks source link

Error: Invalid status code: 1 #125

Closed simioluwatomi closed 3 years ago

simioluwatomi commented 3 years ago

Version of the Action v4.7.2

Describe the bug When there are no ch A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior: I use the action below to run Php CS Fixer in a repo. The action works when there are file changes by Php CS Fixer but fails with the error code in the title and screenshot.

Expected behavior I expect that the action should skip making a commit when there are no changes to commit and not fail the whole workflow.

Screenshots image

Used Workflow

name: Php CS Fixer

on: [push]

jobs:
    php-cs-fixer:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v2
              with:
                  ref: ${{ github.head_ref }}

            - name: Run php-cs-fixer
              uses: docker://oskarstark/php-cs-fixer-ga
              with:
                args: --config=.php_cs

            - uses: stefanzweifel/git-auto-commit-action@v4
              with:
                  commit_message: Apply php-cs-fixer changes
stefanzweifel commented 3 years ago

The Action only creates a commit if there are changes in the repository. So if php-cs-fixer doesn't find anything and nothing happens, git-auto-commit should just "skip itself".

What's unusual in your screenshot, is that there are over 600 lines in the step-log. I assume your repository has some sort of pre-commit hooks and that the code related to those hooks make the step fail.

Could you update your workflow to pass --no-verify to the Action?

name: Php CS Fixer

on: [push]

jobs:
    php-cs-fixer:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v2
              with:
                  ref: ${{ github.head_ref }}

            - name: Run php-cs-fixer
              uses: docker://oskarstark/php-cs-fixer-ga
              with:
                args: --config=.php_cs

            - uses: stefanzweifel/git-auto-commit-action@v4
              with:
                  commit_message: Apply php-cs-fixer changes
+                 commit_options: '--no-verify'

By passing --no-verify the pre-commit hooks are skipped.

simioluwatomi commented 3 years ago

Thanks for the help. It turns out that the problem was with my php-cs config file. After changing setLineEnding("\r\n") to setLineEnding(PHP_EOL) the weird behavior stopped.

Thank you once again