-
Notifications
You must be signed in to change notification settings - Fork 29
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
Request not authenticated by the GitHub Packages? #19
Comments
I cloned your repo and gave it a try: Then I could successfully run the action and package published |
@tonthanhhung Thank you so much for taking the time to try! I've changed |
I'm a bit confused here. The error says
So do you want to publish it to GH packages (npm.pkg.github.com) or to NPM (npmjs.com)? |
@pascalgn I want to publish it on both NPM and GitHub packages. It seem to work for GitHub but not for NPM. |
The error output you've shown is for publishing to GH (URL is npm.pkg.github.com). If you're having problems with publishing to NPM, you need to post that output. |
@bonustrack, there are something you could try to publish to NPM
I suspect that your want to publish to both registry at the same time, I think it's not trivial with this Action. |
I am not sure this is still relevant. However, if you want to publish to GPR and NPM in one workflow you could look at the readme of actions/setup-node: steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '10.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/setup-node@v2
with:
registry-url: 'https://npm.pkg.github.com'
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} They set up node for publishing on NPM with NPM_TOKEN and publish. I hope this helps. |
Quick copy pasta for those interested in only publishing private package on github. You do not need to configure the token manually
|
@hpl002 I believe you do not need to set up node twice. Your code example could be shortened: name: Build and Deploy
on:
push:
branches:
- master
jobs:
publish-gpr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '10.x'
registry-url: 'https://npm.pkg.github.com'
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} Note that you may wish to change the version of node depending on your projects needs. |
For anyone who has the same experience as me, and are getting the below error when attempting to publish their package to the Github Package Registry as part of their Github Actions workflow: I was attempting to use a PAT for authenticating with the Github Package Registry (so named So, although I have not diagnosed the problem, if anyone is experiencing the same BS, I recommend using the documentation (and contributors to this issue too) told |
my workflows .yml file has the I've got a secret in the repo called NPM_TOKEN, and I've got Workflow Permissions set to Read&Write, but I'm still getting the unauthorized error package.json has Been pulling my hair out for hours now
|
@Willshaw do you want to deploy to both NPM and GPR? I believe you have to pass the tokens as NODE_AUTH_KEY, which presents a problem if you want to deploy to both. If you want to deploy to NPM and GPR in one workflow, then take a look at my first answer. |
@cs-intellineers only trying to deploy to GPR, should I drop the NPM_TOKEN flag and change GITHUB_TOKEN to NODE_AUTH_TOKEN then? |
Yes, I believe that would do the trick. Like so: name: Release
on:
pull_request:
push:
branches:
- main-v1
- alpha
- beta
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
- name: Install dependencies
run: npm ci
- name: Release
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release |
Hey dude, thanks for sharing! I'm using this configuration: name: Release
on:
pull_request:
push:
branches:
- master
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js for GitHub
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
registry-url: 'https://npm.pkg.github.com'
- name: Install dependencies
run: npm ci
- name: GitHub Release
run: npm publish --registry=https://npm.pkg.github.com/
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js for NPM
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
- name: NPM Release
run: npm publish --registry=https://registry.npmjs.org
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
@lSilvani Where are you using the |
In all the proposals we always scope the |
@cs-intellineers Could you explain to me why the - name: Create local npm config with auth token to publish to private repository
run: |
echo USERNAME@https://npm.pkg.github.com/ > .npmrc
echo '//npm.pkg.github.com/:_authToken=${{ PRIVATE_NPM_REGISTRY_TOKEN }}' >> .npmrc
cat .npmrc
env:
PRIVATE_NPM_REGISTRY_TOKEN: ${{ github.secret }} It throws an error like this:
Shouldn't it be obsolete how to name the |
I'm not able to publish a new package, for some reason it fail with "Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.". I've double checked the secret from NPM and all looks good. Here is the logs:
My token on NPM:
![image](https://user-images.githubusercontent.com/16245250/89609682-c6cf5700-d8a2-11ea-8211-492493183dcd.png)
I tried to add a secret for "GITHUB_TOKEN" in the repo but GitHub would not allow me to do this. Here is the repo: https://github.com/bonustrack/lock
Any idea what's wrong? Can it be related to the tag i use "0.1.0-rc1" ?
The text was updated successfully, but these errors were encountered: