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

Setting `file_pattern` to an absolute filepath adds all files #228

Closed norman-zon closed 2 years ago

norman-zon commented 2 years ago

Version of the Action v4.14.1

Describe the bug Setting file_pattern to an absolute path does not work as expected.

To Reproduce Steps to reproduce the behavior: 1) Set file_pattern to an absolute path of a single file 2) Modify this file and other file(s) 3) All files get added

Expected behavior Only the the specified file gets added and commited.

Used Workflow

   - name: Push changes to repo
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          file_pattern: ':/shared_infra/README.md'
          disable_globbing: true
          commit_message: "chore(shared_infra): Update README"

Additional context

The log of the action run:

Run stefanzweifel/git-auto-commit-action@v4.14.1
  with:
    file_pattern: :/shared_infra/README.md
    disable_globbing: true
    commit_message: chore(shared_infra): Update README
    repository: .
    commit_user_name: github-actions[bot]
    commit_user_email: github-actions[bot]@users.noreply.github.com
    commit_author: norman-zon <norman-zon@users.noreply.github.com>
    skip_dirty_check: false
    skip_fetch: false
    skip_checkout: false
    create_branch: false

Started: bash /runner/_work/_actions/stefanzweifel/git-auto-commit-action/v4/entrypoint.sh
INPUT_REPOSITORY value: .
INPUT_STATUS_OPTIONS: 
INPUT_BRANCH value: 
From https://github.com/ZeitOnline/xxx
M   shared_infra/README.md
M   shared_infra/main.tf
Your branch is up to date with 'origin/main'.
INPUT_ADD_OPTIONS: 
INPUT_FILE_PATTERN: :/shared_infra/README.md
INPUT_COMMIT_OPTIONS: 
INPUT_COMMIT_USER_NAME: github-actions[bot]
INPUT_COMMIT_USER_EMAIL: github-actions[bot]@users.noreply.github.com
INPUT_COMMIT_MESSAGE: chore(shared_infra): Update README
INPUT_COMMIT_AUTHOR: norman-zon <norman-zon@users.noreply.github.com>
[main dd1980] chore(shared_infra): Update README
 Author: norman-zon <norman-zon@users.noreply.github.com>
 2 files changed, 20 insertions(+), 4 deletions(-)
INPUT_TAGGING_MESSAGE: 
No tagging message supplied. No tag will be added.
INPUT_PUSH_OPTIONS: 
To https://github.com/ZeitOnline/xxx
   01f971d..d2d198  main -> main

I looked at the code of the action and the _add_files function is so straightforward, I have no clue why it would not work as expected.

stefanzweifel commented 2 years ago

I'v never seen absolute paths declared with a colon (:) at the beginning. I've known absolute paths to begin with a slash /.

If you only want to update the README, the following pattern should work for you.

file_pattern: 'shared_infra/README.md'
norman-zon commented 2 years ago

Sorry, I thought :/ was a magic signature for the git repo root. Looks like this is not the case.

file_pattern: 'shared_infra/README.md'

works. Sorry again, for the noise.