A while back I set up a Github Action to build and deploy an app on each code commit. Since it’s good practice to set an expiry date on your Personal Access Tokens, at some point they will expire and you’ll need to update them.
In my project I reference the Access Token using a Github Secret stored in the settings for the project:
To update the expired or about to expire token:
create a new Personal Access Token in your account settings
copy the new token value, update the Secrets in your project and paste the new value
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:
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:
I’ve added a GitHub Action to a project, and when it runs on a push I get this error:
Run npm ci
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: undefined
npm ERR! notsup Actual OS: linux
npm ERR! notsup Actual Arch: x64
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-09-11T23_52_20_527Z-debug-0.log
Error: Process completed with exit code 1.
fsevents is installed/added when doing ‘npm i’ as a dependency when building on MacOS, but it is MacOS specific, and since it’s included in my package.json it’s causing the build on GitHub to fail. Apparently according to this post, it can be optionally included on platforms where it’s available/needed by moving it from the dependencies section in package.json to optionalDependencies instead:
"optionalDependencies": {
"fsevents": "^2.3.2"
}
This resolved my issue, my GitHub Action now runs.