setup-node icon indicating copy to clipboard operation
setup-node copied to clipboard

GITHUB_TOKEN does not have access to other private packages

Open Ignigena opened this issue 7 years ago • 118 comments

Based on the documentation, I have my workflow set up to install from my GitHub Package Registry:

    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-node@v1
      with:
        node-version: 10.x
        registry-url: 'https://npm.pkg.github.com'
    - run: npm ci
      env:
        NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

However, I get a 404 when trying to install any private packages scoped to my account with this configuration. Just to clarify these are private packages within the same account that this repo and workflow exists.

Using the exact same configuration, if I replace with a personal access token I've created, I am able to install private packages without issue.

Ignigena avatar Aug 29 '19 00:08 Ignigena

@Phanatic any idea why this would work with a PAT but not the GITHUB_TOKEN?

damccorm avatar Aug 29 '19 13:08 damccorm

hmm, @Ignigena are the private packages hosted in the same repository as the workflow or are they in another repository under the same account?

Phanatic avatar Aug 29 '19 14:08 Phanatic

The private packages are in another repository under the same account. Both have been published to GPR but as private packages.

Ignigena avatar Aug 29 '19 14:08 Ignigena

Ahh, that's what I figured. The GITHUB_TOKEN we generate is scoped to the repository that is running the Workflow. Unfortunately, this doesn't allow us to install or publish packages from/to other repositories. I'll bring this up in planning and we can figure out how to proceed here.

Phanatic avatar Aug 29 '19 14:08 Phanatic

I figured that might be the case. Would love a solution at least for installing within the same organization. Would rather not have to create a personal access token for each repository -- we're using private NPM modules quite a bit to share business logic/components between all our repos.

We're already forced to do this with NPM's package registry and our TravisCI builds, but was hoping to avoid with Actions and GPR if we can. Totally understand there are probably other implications here, but keep us updated -- would love for this to be as seamless as publishing to GPR is now via an Action 🙂

Ignigena avatar Aug 29 '19 14:08 Ignigena

This is a huge issue, almost impossible to use Actions CI for us now (without that SSH key fiddling we use now for CircleCI). @Phanatic please keep us posted – token working across the whole organization is a must.

krystof-k avatar Sep 07 '19 15:09 krystof-k

@Phanatic, any update on this?

schie avatar Sep 13 '19 19:09 schie

This is indeed a big issue and makes working with the Package Registry much harder. It is very inconvenient having to distribute a personal access token that must be set as a secret on each repository. Please give the GITHUB_TOKEN read permissions to all registries in the same organization.

SanderKnape avatar Sep 23 '19 08:09 SanderKnape

As of today, it now works. See #53

PeterHewat avatar Sep 24 '19 20:09 PeterHewat

No, it isn't fixed. #53 is about publishing a package, which can be done. This is about pulling packages from other private repos, which can't be done, it requires a personal access token.

This is also a big issue for me and my company. There should be a way to have an org token that gives read access to the org's packages. Or give GITHUB_TOKEN to other packages of the same org

negebauer avatar Sep 25 '19 19:09 negebauer

This is about pulling packages from other private repos, which can't be done, it requires a personal access token.

A PAT is the solution for other private repos.

This also isn't an issue with setting up node (this repo).

If you have a request for the service to expand the scope of the token, please leave feedback on community

https://github.community/

Thanks!

bryanmacfarlane avatar Oct 16 '19 13:10 bryanmacfarlane

Posted.

krystof-k avatar Oct 20 '19 15:10 krystof-k

I posted a follow up issue to reproduce a similar "Error: 404 Not Found" bug on https://github.community/t5/GitHub-Actions/Package-not-found-in-the-Github-Registry/m-p/31685/highlight/false#M864

What repository do we post GPR related issues like the one i just mentioned above?

Alappin avatar Nov 27 '19 01:11 Alappin

I believe github.community is the right place (unless it is actually related to setup-node action in this repo).

krystof-k avatar Nov 27 '19 10:11 krystof-k

Why is this closed, this is a bug

wpitallo avatar Dec 01 '19 11:12 wpitallo

@bryanmacfarlane a PAT is "personal" and can't be scoped to a single org, means a PAT has access to all my packages across all my orgs. That's not a solution to me. The GITHUB_TOKEN should have package:read access to all packages in the same org.

PatrickHeneise avatar Jan 08 '20 08:01 PatrickHeneise

Here's another community thread related to this issue. As of today there's still no solution, only the (unsuitable) Personal Access Token workaround.

mogelbrod avatar Jan 27 '20 16:01 mogelbrod

@wpitallo - this is closed here because there's nothing that this repo or the code in this repo can do to implement that feature. This is an individual action. Service issues and feature requests are tracked in GitHub community.

@PatrickHeneise package:read won't help here since actions are not packages. They are pulled and run from a repo at the ref specified. Per above there's feature work proposed on the backlog to allow actions to be able to published as packages and other service feature work to control scope of the token (the current behavior is defined as the repo triggering the workflow).

Agreed, the PAT option is a workaround and not a solution.

Hope that helps clarify.

bryanmacfarlane avatar Jan 27 '20 23:01 bryanmacfarlane

Thanks, hope that is implemented soon. We removed our "GitHub service user" when we removed 3rd party CI and build services. Unbelievable that I need to create and pay for a service user again just to have org-level access to packages within the GitHub platform.

PatrickHeneise avatar Jan 28 '20 06:01 PatrickHeneise

Having the same issue myself:

  • we have 2 private repos under one org that are published as npm packages in the GPR.
  • One of them has as a depencency the other one.
  • If you try to run npm i from a github action in the one that fetches the other private module, it says npm package "[...]" does not exist under owner "[...]", which is not true, and responds with a 404 error.

Certainly, adding a PAT solved the issue... But having as PAT the secrets.GITHUB_TOKEN should be enough! As it is to npm publish.

I think this is a similar situation as the one described by @Alappin.

paulmelero avatar Apr 23 '20 22:04 paulmelero