I want to add and commit a file with Python script to a repo running on the GitHub Actions server.
I am committing a file by running the following in my main.py file:
import os
FILE = './file.txt'
os.system(f'git add {FILE}')
os.system("git commit -m 'update file'")
On GitHub actions, I am running Python script as:
- name: Commit file
run: python commit_file.py
But there isn't any scripts commits on the repo master branch after GitHub actions run.
On my local machine, os.system("git commit -m 'update file'") command is running normally, and I can verify that the commit exist with the git log command. On the GitHub actions, the following error occurs:
Run Commit file
python commit_file.py
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 <runner@fv-az112-319.bzi55m0t1ufu323ye4cn5ktith.xx.internal.cloudapp.net>) not allowed
EDIT: I've added two more lines which will configure git credentials:
os.system('git config --global user.email "[email protected]"')
os.system('git config --global user.name "GitHub Actions"')
and now, the warnings are gone, but there is still no commit on the repo.
git pushat the end of the script?