gp-pages deploy fails when run from GitHub Action: Author identity unknown

I’m calling gh-pages from a GitHub Action, and at the point when gh-pages is called by the Action, it fails with this error:

> gh-pages -d build

Author identity unknown

*** Please tell me who you are.

Following this recommendation on a similar posted issue, I updated the ‘npm run build’ script in my package.json to pass the -u option with the github-actions-bot userid:

    "deploy": "gh-pages -d build -u 'github-actions-bot <support+actions@github.com>'",

After adding this and re-running, now I have a different error:

> gh-pages -d build -u 'github-actions-bot <support+actions@github.com>'

fatal: could not read Username for 'https://github.com': No such device or address

Apparently to allow the Action to use actions/checkout to access your repo you must use a Personal Token per additional instructions here.

To create a new access token, access your account settings, then Developer Settings:

To add the token value as a secret to your project, add a new secret via settings on the repo that your Action is accessing:

After paying more attention to the Action log, the checkout step was actually working and completing as expected, it was the ‘npm run deploy’ step that was failing with same error as shown in the linked post above. Following the same advice to use the access token to resolve the ‘Could not read username’ error, I updated the ci.yml again to add the reference to the token as part of setting the remote repo url:

- name: Deploy
  env:
    MY_EMAIL: kevin.hooke@gmail.com
    MY_NAME: kevinhooke
  run: |
    git config --global user.email $MY_EMAIL
    git config --global user.name $MY_NAME
    git remote set-url origin https://$MY_NAME:${{ secrets.GH_SECRET }}@github.com/kevinhooke/my-example-project.git
    npm run deploy
  • the git config steps set the git user’s email and name properties within the context of the Github Action
  • the ‘git remote set-url’ specifies the repo url including my userid and the Personal Access Token retrieved from the GitHub Secret.

Problem solved, now the action works as expected and publishes this project’s GitHub pages on every commit!

One Reply to “gp-pages deploy fails when run from GitHub Action: Author identity unknown”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.