How to Use Git Commit in GitHub Actions

If you’ve tried to use git commit in GitHub Actions before, you may have come across the following error messages:

Author identity unknown
*** Please tell me who you are.

Run
  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name
    (for <[email protected]>) not allowed
Author identity unknown

This can easily be fixed by doing the following:

Running Git Commit directly in GitHub Actions

name: Commit date to master
on: push
jobs:
  date:
    runs-on: ubuntu-latest
    steps:
      - name: checkout
        uses: actions/checkout@v2
      - name: save current date
        run: date > date.log
      - name: setup git config
        run: |
          git config user.name "GitHub Actions Bot"
          git config user.email "<>"
      - name: commit
        run: |
          git add date.log
          git commit -m "new commit message"
          git push origin master

Notice the addition of the git config items:

git config user.name "GitHub Actions Bot"
git config user.email "<>"

An example where python calls git commit internally

name: Cron
on:
  schedule:
    - cron: '* * * * *'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: setup python
        uses: actions/setup-python@v2
        with:
          python-version: 3.8
      - name: Run a one-line script
        run: |
          git config user.name "GitHub Actions Bot"
          git config user.email "<>"
          python run.py