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

Checks never finish if you add a commit to a PR #185

Closed CodeCasterNL closed 2 years ago

CodeCasterNL commented 2 years ago

Version of the Action v4.1.2

Describe the bug When php-cs-fixer fixes some code and commits it through this git-auto-commit-action, then the pull request's checks will never finish.

To Reproduce Steps to reproduce the behavior:

  1. Create a branch
  2. Commit then push some code that php-cs-fixer would love to correct
  3. Create a PR for that branch into another
  4. The checks run for the initial commit
  5. The check creates an additional commit
  6. The checks never run on this additional commit

Expected behavior The checks should re-run or something?

Screenshots Pull Request: PR checks

Pending check on fixed commit: PR checks (waiting)

Succesful checks on initial commit: PR checks successful

Used Workflow

name: Fix Code Style and Build

on:
  pull_request:

jobs:
  php-cs-fixer:
    name: PHP Coding Standards Fixer on ${{ matrix.operating-system }})
    strategy:
      fail-fast: false
      matrix:
        operating-system: [ ubuntu-latest ]
        php-versions: [ '7.4' ]

    runs-on: ubuntu-latest
    steps:
      - name: Git Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php-versions }}
          tools: php-cs-fixer

      - name: Run php-cs-fixer
        run: php-cs-fixer fix -v

      - name: Commit php-cs-fixer changes, if any
        uses: stefanzweifel/git-auto-commit-action@v4.1.2
        with:
          commit_message: fix: Apply php-cs-fixer changes
          branch: ${{ github.head_ref }}

  symfony:
    name: Symfony (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
    needs: php-cs-fixer
    strategy:
      fail-fast: false
      matrix:
        operating-system: [ubuntu-latest]
        php-versions: ['7.4']

    runs-on: ${{ matrix.operating-system }}

    services:
      # ...
    steps:

      - name: Git Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      # do the build...
stefanzweifel commented 2 years ago

I assume you're using protected branches and have defined these workflows as "required"? This problem is related to the fact, the the commit made by git-auto-commit does not trigger a new Workflow run.

See: https://github.com/stefanzweifel/git-auto-commit-action#commits-made-by-this-action-do-not-trigger-new-workflow-runs

The solve this problem, you would have to either:

Another user had a similar issue in #163.

CodeCasterNL commented 2 years ago

@stefanzweifel thanks for the quick reply. I searched, but didn't find that issue.

We'll try with a PAT and ifs to not run the rest of the workflow if your nice action committed something, thanks!

stefanzweifel commented 2 years ago

Closing this issue, as the issue seems to be resolved.