how does one commit from an action?

I’m trying to commit to gh-pages from an action. Something like:




      - name: first_step

         run: |

           git config --global ${GITHUB_ACTOR}

           git config --global ${GITHUB_ACTOR}
           git add ${GITHUB_WORKSPACE}/my-docs
           git commit -m "committing my-docs"
           git subtree push --prefix my-docs origin gh-pages

seems to fail at the push command with 

fatal: could not read Username for '': No such device or address
##[error]Process completed with exit code 128.

I am faking that config. It’s not exposed in the context and the git commit fails without it.

*** Please tell me who you are.


  git config --global ""
  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 <>) not allowed
##[error]Process completed with exit code 128.

At this point, the gh-pages orphaned branch is not created. Does that make a difference?


oh - and this is a private repo, and for the sake of argument, I tried to use an email that was hardcoded, to no avail. 

Any help is appreciated. 

try this:

git remote add github "https://$GITHUB_ACTOR:$$GITHUB_REPOSITORY.git"
git pull github ${GITHUB_REF} --ff-only

git add ...

git commit -m "Update native model"
git push github HEAD:${GITHUB_REF}

To avoid having to set up git’s and settings, you could also use GitHub’s API to commit and push changes from an action.

Here is an example where I update a YAML file and push changes using the github3 Python library:

import os

import github3
import yaml

MAIN_BRANCH = 'master'

# Read updated contents of galaxy.yml.
# NOTE: Make changes to the galaxy.yml file before running this script.
with open('galaxy.yml') as f:
    galaxy_file =

# Connect to GitHub API and push the changes.
github = github3.login(token=os.environ['GITHUB_TOKEN'])
repository = github.repository(*os.environ['GITHUB_REPOSITORY'].split('/'))
github_galaxy_yml = repository.file_contents('/galaxy.yml', ref=MAIN_BRANCH)
pushed_change = github_galaxy_yml.update(
    'Bump version',
print("Pushed commit {} to {} branch:\n {}".format(

This is a solution written directly as a run (bash) step:

Note that GHA_DEPLOY_KEY is a private key that was uploaded as a secret, and the corresponding public key was uploaded as a deploy key to the target repo. The private key pair was created with:

ssh-keygen -t ed25519

The advantage of this approach is that the scope of deploy keys is more limited than that of tokens.

1 Like

This action does what you want


If you use actions/checkout@v2 instead of actions/checkout@v1 the login is done automatically. You can git commit and git push without setting up anything :slight_smile:


@dlunch This is Helpful

The documentation for v2 specifically mentions that you need to configure name and email:

I tried it today without name and email config and it didn’t work. Could you elaborate on your workflow that doesn’t require that configuration?


I’m happy with github’s advice in @eps1lon’s link, but here’s something else I’ve used:

git config --local "$(git log --format='%ae' HEAD^!)"
git config --local "$(git log --format='%an' HEAD^!)"

It just copies the name and email from the last commit.


If somebody from Github could provide a current solution that would be good. I have an action here that (I think) follows the above advice (as far as I can make it out) and runs fine. However it appears to have no impact on the repository.