6

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

 1 year ago
source link: https://www.kevinhooke.com/2022/11/10/gp-pages-deploy-fails-when-run-from-github-action-author-identity-unknown/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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 <[email protected]>'",

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

> gh-pages -d build -u 'github-actions-bot <[email protected]>'

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:

Personal-Access-Tokens.png?resize=525%2C608&ssl=1

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:

image.png?resize=525%2C1031&ssl=1

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: [email protected]
    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!

CategoriesKev's BlogTagsci/cd, github, github actions, github pages

Leave a Reply Cancel reply

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

Comment *

Name *

Email *

Website

Save my name, email, and website in this browser for the next time I comment.

Notify me of follow-up comments by email.

Notify me of new posts by email.

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

Post navigation


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK