Review of the git-auto-commit-actio
Tags: devops, github, git
Published: 2020-08-05 14:16:56

---
title: Review of the git-auto-commit-actio
published: true
date: 2020-07-05 05:00:00 UTC
tags: devops, github, git
series: actions
canonical_url: https://waylonwalker.com/blog/git-auto-commit-action-review/
cover_image: https://waylonwalker.com/git-auto-commit-action-review.png
---

👀 see an issue, edit this post on <a href='https://github.com/WaylonWalker/waylonwalkerv2/edit/main/src/pages/blog/git-auto-commit-action-review.md' >GitHub</a>

Follow me on Twitter [@_waylonwalker](https://twitter.com/intent/follow?screen_name=_waylonwalker)

---

Check out the repo for [git-auto-commit-action](https://github.com/stefanzweifel/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.


<p style='text-align: center'>
<a href='https://waylonwalker.com/blog/github-actions-syntax'>
  <img
    style='width:500px; max-width:80%; margin: auto;'
    src="https://waylonwalker.com/github-actions-syntax-rm.png"
    alt="GitHub Actions Syntax article card"
  />
  </a>
</p>

> 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:

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

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

## Usage
_from the repo_

``` yaml
- uses: stefanzweifel/git-auto-commit-action@v4
  with:
    # 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 https://git-scm.com/docs/git-commit 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
    # - https://git-scm.com/docs/git-add#Documentation/git-add.txt-ltpathspecgt82308203
    # - https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec
    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_user_email: my-github-actions-bot@example.org
    commit_author: Author <actions@github.com>

    # 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.

<TABLE>
  <TR>
    <TD>
      <a href='https://waylonwalker.com/blog/four-github-actions-website'>
      <img
        style='width:250px; max-width:80%; margin: auto; float: left'
        src="https://waylonwalker.com/four-github-actions-website-rm.png"
        alt="GitHub Actions Syntax article card"
        />
      </a>
    </TD>
    <TD>
      <a href='https://waylonwalker.com/blog/four-github-actions-python'>
      <img
        style='width:250px; max-width:80%; margin: auto; float: right;'
        src="https://waylonwalker.com/four-github-actions-python-rm.png"
        alt="GitHub Actions Syntax article card"
        />
      </a>
    </TD>
  </TR>
</TABLE>

---

<table>
<tbody>
  <tr>
    <td colspan="5">
      I have been writing short snippets about my mentality breaking into the tech/data industry in my <a href="https://waylonwalker.com/newsletter">newsletter</a>, 👉 check it out and lets get the conversation started.
    </td>
    <td colspan="1">
      <p><a href="https://waylonwalker.com/newsletter"><img src="https://dev-to-uploads.s3.amazonaws.com/i/lia4jondde8x0qdxjb5y.png" alt="Sign up for my Newsletter"></a></p>
    </td>
  </tr>
  <tr>
    <td></td>
    <td></td>
    <td><a href="https://twitter.com/_waylonwalker"><img width='30' src="https://github.com/WaylonWalker/WaylonWalker/blob/main/icon/twitter.png?raw=true"></a></td>
    <td><a href="https://instagram.com/_waylonwalker"><img width='30' src="https://github.com/WaylonWalker/WaylonWalker/blob/main/icon/instagram.jpg?raw=true"></a></td>
    <td><a href="https://www.linkedin.com/in/waylonwalker/"><img width='30' src="https://github.com/WaylonWalker/WaylonWalker/blob/main/icon/linkedin.png?raw=true"></a></td>
    <td><a href='https://www.buymeacoffee.com/bBdtMQO'>
      <img src='https://cdn.buymeacoffee.com/buttons/lato-violet.png' width='200px' />
      </a>
    </td>
  </tr>
  <tr>
    <td></td>
    <td colspan="5" align=center style="text-align: center">
      👀 see an issue, edit this post on <a href='https://github.com/WaylonWalker/waylonwalkerv2/edit/main/src/pages/blog/git-auto-commit-action-review.md' >GitHub</a>
    </td>
  </tr>
</tbody>
</table>