setup-node: Unable to publish to the GitHub Registry
I’ve been following this document (and the README): https://github.community/t5/GitHub-Actions/bd-p/actions, specifically the part about cross publishing between npmjs and the GitHub registry, but I can’t seem to get it to work. This is my workflow: https://github.com/JamesIves/github-pages-deploy-action/blob/dev/.github/workflows/publish.yml
The problem I’m having is that every time I publish it says I must authenticate, except it’s providing a URL related to the npmjs registry: 401 Unauthorized - PUT https://registry.npmjs.org/github-pages-deploy-action - You must be logged in to publish packages.
This is the full log. Am I missing something here or is this a bug?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 15
- Comments: 23 (2 by maintainers)
Commits related to this issue
- Remove publish to gpr * Suspect it needs scoped packages. See https://github.com/actions/setup-node/issues/130 — committed to anaynayak/aws-cloudwatch-annotations by anaynayak 4 years ago
- Define scope and registry URL for publication Package publication fails with `'@keep-network/keep-ecdsa@1.6.0-pre.1' is not in the npm registry` error. Here we try to workaround the problem by explic... — committed to keep-network/keep-ecdsa by nkuba 3 years ago
- Define scope and registry URL for publication Package publication fails with `'@keep-network/keep-ecdsa@1.6.0-pre.1' is not in the npm registry` error. Here we try to workaround the problem by explic... — committed to keep-network/keep-ecdsa by nkuba 3 years ago
- chore(deps-dev): bump husky from 4.3.6 to 4.3.7 (#130) Bumps [husky](https://github.com/typicode/husky) from 4.3.6 to 4.3.7. - [Release notes](https://github.com/typicode/husky/releases) - [Commits... — committed to deining/setup-node by dependabot[bot] 3 years ago
I’ve managed to resolve this with my actions with the following workflow file:
https://github.com/JamesIves/github-pages-deploy-action/blob/dev/.github/workflows/publish.yml
I also added the scope to the package.json file here: https://github.com/JamesIves/github-pages-deploy-action/blob/dev/package.json#L2
It now cross publishes between npm and GitHub correctly. Thanks to everyone for their help resolving this. I’ll leave this open as I still believe this is an issue with setup-node.
My repo was having a similar issue to this one. Replacing the package name in package.json by adding the scope to it solved it for Github Package Registry.
My fix: https://github.com/jojobyte/traefikjam/blob/master/.github/workflows/node-build.yml#L40
This lets you publish to NPM with an unscoped package name and GPR with a scoped package name.
Amazing that this hasn’t been patched yet. Very misleading that the published actions is broken(for this particular use case) by default.
Please see @JamesIves post for remedy
Yes exactly. Just tried it and it started to work. You can then publish the same thing in NPM as well, as long as you add
npm publish —access public
. Otherwise scoped packages there are private by default.Interesting, npmjs seems to pass for me when specifying
registry-url: 'https://registry.npmjs.org'
, but only the GitHub registry seems to fail for me. I’m guessing that whatever mechanism that overrides the.npmrc
file isn’t behaving correctly in my case.So, I don’t know if this applies to your situation or not, but I was having the exact same issue. I came across this doc
https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages#publishing-a-package-using-publishconfig-in-the-packagejson-file
I added this to my repo and it worked.
Good luck
Interesting, I can’t seem to get it to work for the life of me. Tried in several repositories now, the first publish to
npmjs.org
works. It goes wrong when I try and specify anything besides npmjs. I’ve even try separating this into separate steps incase there’s some form of conflict or permission issue.However it still doesn’t seem to be correctly overwriting the
.npmrc
file after the second call tosetup-node
as I get this error (thePUT
request is still being made tonpmjs.org
instead ofnpm.pkg.github.com
)401 Unauthorized - PUT https://registry.npmjs.org/github-pages-deploy-action - You must be logged in to publish packages.