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 "[email protected]" git config --global "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 "GitHub Actions Bot" git config "<>" - 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 "GitHub Actions Bot" git config "<>"
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 "GitHub Actions Bot" git config "<>" python
Code language: YAML (yaml)
Notify of
1 Comment
Oldest Most Voted
Inline Feedbacks
View all comments
Dawie de Villiers
3 months ago

Thanks a TON!