Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token Authentication Failure on Publish to Custom Registry #33

Closed
MitchCroft opened this issue Mar 9, 2021 · 2 comments
Closed

Token Authentication Failure on Publish to Custom Registry #33

MitchCroft opened this issue Mar 9, 2021 · 2 comments

Comments

@MitchCroft
Copy link

Not entirely sure if this is an issue or a misconfiguration on my part but any guidence would be greatly appreciated.

I've been trying to setup a private registry that I can use to host various Unity packages that I've created over the years in a single location, using this tool to automatically publish updates.

I setup the GitHub action following the example in the readme for the package with some slight tweaks to point it at my custom package registry.

on:
  push:
    branches: [ packages ]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: 10
      - run: npm install
      - name: NPM Publish
        uses: JS-DevTools/npm-publish@v1
        with:
          token: ${{ secrets.NPM_TOKEN }}
          registry: [RegistryAddress:Port]  # Substituted for privacy
          package: ${{ github.workspace }}/Assets/MCU_Core/package.json

Everything appears to work, running with dry-run: true runs through the action as one would expect. It generates a package and stops short of publishing it. When the version in the package.json is not modified it's able to read the previous version and not publish the package.

But when trying to run the actual action to publish updates, I seem unable to fix the npm ERR! code E401 Unable to authenticate, your authentication token seems to be invalid error that is caused. I've used powershell with my authentication token to call npm publish --registry=[RegistryAddress:Port]/:_authToken=[AutomationAuthToken] manually with success. I've crawled through the forum posts to try and determine what the cause could be (package.json setup, npmjs.com account verification etc.).

I've attached the log for the NPM Publish step in case that's any help
NPMPublishStep.log

Any assistance in resolving this would be greatly appreciated, just starting out with this kind of setup and am open to any suggestions you may have.

@antonkatz
Copy link

Might have something similar on my end:

on:
  push:
    branches:
      - 'develop'

name: Create Package

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 15
      - run: yarn install
      - uses: JS-DevTools/npm-publish@v1
        with:
          tag: develop
          registry: ***** (github registry)
          token: ${{  secrets.GITHUB_TOKEN }}

just threw this error

Run JS-DevTools/npm-publish@v1
npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The "path" argument must be of type string. Received undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-03-19T23_31_35_258Z-debug.log
Error: Error: Unable to publish ***** v0.1.49 to NPM. 
npm publish --tag develop exited with a status of 1.
    at Object.publish (/home/runner/work/_actions/JS-DevTools/npm-publish/v1/src/npm.ts:112:13)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

ProcessError: npm publish --tag develop exited with a status of 1.
    at normalizeResult (/home/runner/work/_actions/JS-DevTools/npm-publish/v1/node_modules/@jsdevtools/ez-spawn/lib/normalize-result.js:31:1)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/JS-DevTools/npm-publish/v1/node_modules/@jsdevtools/ez-spawn/lib/async.js:79:1)
    at ChildProcess.emit (events.js:210:5)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)

@MitchCroft
Copy link
Author

Managed to resolve my issue. Looks like the token I had generated for authentication was for npmjs.org instead of my private registry. After much struggling with being able to create an authentication token I eventually found carlosen14's post describing the process of logging in to NPM on the registry and then copying out the authentication token that generates.

@mcous mcous closed this as not planned Won't fix, can't repro, duplicate, stale Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@mcous @antonkatz @MitchCroft and others