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
2.07k stars 231 forks source link

changed files no committed #233

Closed staabm closed 2 years ago

staabm commented 2 years ago

Version of the Action v4

Describe the bug it seems the action does not commit all changed files (files in subfolders are left behind).

the action properly detects that the files contain changes, as can be seen in the github action log:

Run stefanzweifel/git-auto-commit-action@v4
  with:
    commit_message: Apply phpstan-baseline changes
    file_pattern: *.neon
    repository: .
    commit_user_name: github-actions[bot]
    commit_user_email: github-actions[bot]@users.noreply.github.com
    commit_author: gh-kundenserver <gh-xxx@users.noreply.github.com>
    skip_dirty_check: false
    skip_fetch: false
    skip_checkout: false
    disable_globbing: false
    create_branch: false
  env:
    COMPOSER_PROCESS_TIMEOUT: 0
    COMPOSER_NO_INTERACTION: 1
    CACHE_RESTORE_KEY: Linux-php-8.0.[2](https://github.com/complex-gmbh/php-clxproductnet/runs/7521420905?check_suite_focus=true#step:15:2)1-composer---prefer-dist---no-progress---no-suggest-locked-
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/complex-gmbh/php-clxproductnet
 * [new branch]      smu-pricing             -> origin/smu-pricing
M   composer.json
M   phpstan-baseline.neon
M   scripts/phpstan-baseline.neon
Your branch is up to date with 'origin/types'.
INPUT_ADD_OPTIONS: 
INPUT_FILE_PATTERN: *.neon
INPUT_COMMIT_OPTIONS: 
INPUT_COMMIT_USER_NAME: github-actions[bot]
INPUT_COMMIT_USER_EMAIL: github-actions[bot]@users.noreply.github.com
INPUT_COMMIT_MESSAGE: Apply phpstan-baseline changes
INPUT_COMMIT_AUTHOR: gh-xxx<gh-xxx@users.noreply.github.com>
[types 16[8](https://github.com/complex-gmbh/php-clxproductnet/runs/7521420905?check_suite_focus=true#step:15:8)246e] Apply phpstan-baseline changes
 Author: gh-kundenserver <gh-xxx@users.noreply.github.com>
 1 file changed, [11](https://github.com/complex-gmbh/php-clxproductnet/runs/7521420905?check_suite_focus=true#step:15:11) insertions(+), 1 deletion(-)
INPUT_TAGGING_MESSAGE: 
No tagging message supplied. No tag will be added.

.. only M phpstan-baseline.neon is committed, but not M scripts/phpstan-baseline.neon

To Reproduce workflow step:

      - name: Commit changed files
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Apply phpstan-baseline changes
          branch: ${{ github.head_ref }}
          file_pattern: '*.neon' 

Expected behavior since the pattern is *.neon I would expect the action to commit all changed *neon files, no matter in which directory they are contained

Screenshots n/a Used Workflow

# Paste the Workflow you've used here

Additional context I am pretty sure this worked in the past, and it seems to have regressed in a recent release?

stefanzweifel commented 2 years ago

The responsible line for adding files to the commit has not been updated in the last 15 months.

However, git-status and git-add differs as $INPUT_FILE_PATTERN is in quotes in git-status; but not in git-add. If I remember correctly, I did this on purpose to prevent globbing. 🤔

Have to do some manual testing.

stefanzweifel commented 2 years ago

I've added a test in https://github.com/stefanzweifel/git-auto-commit-action/commit/dce7e85096193516db2ae686bd562faf5bc7f4ea to cover this scenario.

To commit all files, it seems you have to add a pattern to explictly look for neon-files in sub folders. (Not sure what the correct technical term is here)

In your example it would be *.neon **/*.neon

  - name: Commit changed files
    uses: stefanzweifel/git-auto-commit-action@v4
    with:
      commit_message: Apply phpstan-baseline changes
      branch: ${{ github.head_ref }}
-     file_pattern: '*.neon' 
+     file_pattern: '*.neon **/*.neon' 

Could you give this a try?

staabm commented 2 years ago

Thx for the investigation

Should file_pattern: '**.neon' also work then?

stefanzweifel commented 2 years ago

@staabm Yeah that seems to work too.

Triggered a test run in a test repo with file_pattern: '**.php':

PHP files in the root and in a nested folder have been commited: https://github.com/stefanzweifel/git-auto-commit-action-demo-app/commit/0e9ba3a0ef5397165183aad9da0a3ed87cdb1ba7

staabm commented 2 years ago

ok cool, thank you.

from my POV this issue can be closed