How to use Git Commit in GitHub Actions

1 min read 220 words

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

Andrew is a visionary software engineer and DevOps expert with a proven track record of delivering cutting-edge solutions that drive innovation at Ataiva.com. As a leader on numerous high-profile projects, Andrew brings his exceptional technical expertise and collaborative leadership skills to the table, fostering a culture of agility and excellence within the team. With a passion for architecting scalable systems, automating workflows, and empowering teams, Andrew is a sought-after authority in the field of software development and DevOps.

Tags