Review of the git-auto-commit-action

Check out the repo for git-auto-commit-action.

It's a really cool GitHub action that will automatically commit files changed during the action. I was using this to render a new readme based on a template.

This has been by far the easiest way to commit back to a repo that I have seen. Other patterns often require fully setting up the git user and everything. While it's not all that hard, this action already has all of that covered.

You must give it a commit message and thats it. Optionally you can configure a number of things. Its possible to configure the commit_user_name, commit_user_email, and commit_author. I often also scope the file_pattern to a certain subset of files.

GitHub Actions Syntax article card

If you're new to actions check out this article on using actions.

GitHub Actions Syntax article card

If you're new to actions check out this article on using actions.

You do need to be careful to checkout the repo just a bit different than normal.

Limitations & Gotchas

directly from the repo

Checkout the correct branch

You must use action/checkout@v2 or later versions to checkout the repository. In non-push events, such as pull_request, make sure to specify the ref to checkout:

- uses: actions/checkout@v2
    ref: ${{ github.head_ref }}

You have to do this do avoid that the checkout-Action clones your repository in a detached state.


from the repo

- uses: stefanzweifel/git-auto-commit-action@v4
    # Required
    commit_message: Apply automatic changes

    # Optional branch to push to, defaults to the current branch
    branch: feature-123

    # Optional options appended to `git-commit`
    # See for a list of available options
    commit_options: '--no-verify --signoff'

    # Optional glob pattern of files which should be added to the commit
    # See the `pathspec`-documentation for git
    # -
    # -
    file_pattern: src/*.js tests/*.js

    # Optional local file path to the repository
    repository: .

    # Optional commit user and author settings
    commit_user_name: My GitHub Actions Bot
    commit_author: Author <>

    # Optional tag message
    # Action will create and push a new tag to the remote repository and the defined branch
    tagging_message: 'v1.0.0'

    # Optional options appended to `git-push`
    push_options: '--force'

    # Optional: Disable dirty check and always try to create a commit and push
    skip_dirty_check: true

More Actions

If you're new to actions check out these articles on using actions.

GitHub Actions Syntax article card GitHub Actions Syntax article card

👀 see an issue, edit this post on GitHub

If you found value in this post
and want to send a tip.

Buy Me A Coffee

Check out my otherblogs

tweet about this post and it will show up here.