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.96k stars 226 forks source link

error when nothing to commit #177

Closed GmBodhi closed 2 years ago

GmBodhi commented 2 years ago

Version of the Action v4

Describe the bug Whenever local is up to date with origin the process fails and resulting in this error:

To Reproduce Steps to reproduce the behavior: Try to commit without making any changes.

Expected behavior The process shouldn't fail and resulting in a workflow failure unless we specify to ignore the error

Screenshots image

Used Workflow

image

stefanzweifel commented 2 years ago

Thanks for reporting!

Currently can't figure out what the problem here is. skip_dirt_check is covered by a test and your workflow basically uses all the default values except the commit message. 🤔

Will have a closer look over the days.

stefanzweifel commented 2 years ago

@GmBodhi Unfortunately I can't reproduce your issue.

In https://github.com/stefanzweifel/git-auto-commit-action/commit/f6048aa2acaebea86483c05cd872213addabc819 I've added a test that covers your exact use case (I think?). Hover, the test passes without throwing errors.

Could you share more about your use case? Pasting your workflow here would probably help. What is happening before git-auto-commit-action is used?

GmBodhi commented 2 years ago

Actually, I have hundreds of files. Probably 300 I guess.

GmBodhi commented 2 years ago
name: Example

on:
  workflow_dispatch:
  schedule:
    - cron: "0 0 * * 1"

jobs:
  Example:
    runs-on: windows-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Install Node v14
        uses: actions/setup-node@v2
        with:
          node-version: 14

      - name: Install Dependencies
        run: yarn install

      - name: Run Config
        run: yarn run config

      - name: Generate examples
        run: |
          cd example-processor
          node index.js
      - name: Generate Config
        run: |
          cd example-processor
          node generateConfig.js
      - name: Format Code
        run: |
          npm i prettier -g
          git pull -a
          prettier --write .
      - name: Commit changes
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: "automated: Examples generated (actions)"
          file_pattern: "."
          skip_dirty_check: false
          skip_fetch: false

That git pull -a was added for extra safety, but either way the result was same

GmBodhi commented 2 years ago

It's for create-three-app, We generate webpack compatible packages from threejs.org/examples, there are plenty of them.

GmBodhi commented 2 years ago

This is an example: https://github.com/GmBodhi/create-three-app/runs/3708857982

stefanzweifel commented 2 years ago

@GmBodhi Thanks for the links and your workflow file. The problem seems to be related to the OS you're running your jobs on: Windows.

I have written git-auto-commit to be run on UNIX based systems and not on Windows. (I currently have no intentions to support Windows. In #178 I've tried to update our test suite to run on Windows too, but that immediately failed due to the needed dependencies. I also haven't touched a Windows machine in the last 6 years.)

I've forked your project and updated the Workflow file to run on ubuntu-latest.

The run was successful and the Action created a commit: https://github.com/stefanzweifel/create-three-app/commit/3111fd6e89b12141421b1258b32993717f4ed185

Please update your Workflow file like this:

-runs-on: windows-latest
+runs-on: ubuntu-latest

I will update the README shortly to mention that the Action is not compatible with Windows.

GmBodhi commented 2 years ago

Okay, thank you.

jetersen commented 2 years ago

https://github.com/release-drafter/release-drafter/runs/4890119635?check_suite_focus=true#step:7:35 This fails on ubuntu 😓

Invalid status code: 1

One way to fix it is:

git diff-index --quiet HEAD || git commit -m 'bla'

Or

git commit -m 'bla' || true