Skip to content

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
Code language: JavaScript (javascript)

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/[email protected] - 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
Code language: YAML (yaml)

Notice the addition of the git config items:

git config user.name "GitHub Actions Bot" git config user.email "<>"
Code language: Bash (bash)

An example where python calls git commit internally

name: Cron on: schedule: - cron: '* * * * *' jobs: build: runs-on: ubuntu-latest steps: - uses: actions/[email protected] - name: setup python uses: actions/[email protected] 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
Code language: YAML (yaml)

See also  [Solved] fatal: Could not read from remote repository with Git
Tags:
Subscribe
Notify of
guest
2 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Bizz
Bizz
17 days ago

Brill!

Dawie de Villiers
8 months ago

Thanks a TON!

2
0
Would love your thoughts, please comment.x
()
x