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

npmToken with template secrets and npmrc does not work #31303

Open
rarkins opened this issue Sep 10, 2024 · 4 comments
Open

npmToken with template secrets and npmrc does not work #31303

rarkins opened this issue Sep 10, 2024 · 4 comments
Assignees
Labels
core:config Related to config capabilities and presets priority-2-high Bugs impacting wide number of users or very important features type:bug Bug fix of existing functionality

Comments

@rarkins
Copy link
Collaborator

rarkins commented Sep 10, 2024

For context, my original setup—which needed migration—looks like this:

"encrypted": {
  "npmToken": "wcFMA/xDdHCJBTolAQ/........."
}
"npmrc": "@<ORG_NAME>:registry=https://npm.pkg.github.com/\n//npm.pkg.github.com/:_authToken=${NPM_TOKEN}",

Note

<ORG_NAME> is replaced with the actual organization name that contains private NPM packages

I couldn't get npmToken to work again after migrating to secret and unwrapping it from the encrypted object. Renovatebot complains that it has no access to the private packages, indicating it has issues access the secret.

I've tried:

  • Copying the old encrypted token and pasting it as a secret ("migrate" secret)
  • Copying the unencrypted token and pasting it

Neither worked.

// WARNING: This does not work
"npmToken": "{{ secrets.NPM_TOKEN }}",
"npmrc": "@<ORG_NAME>:registry=https://npm.pkg.github.com/\n//npm.pkg.github.com/:_authToken=${NPM_TOKEN}",

What worked for me is to introduce it as a hostType entry:

"hostRules": [
  {
    "matchHost": "https://npm.pkg.github.com/",
    "hostType": "npm",
    "token": "{{ secrets.NPM_TOKEN }}"
  }
],
"npmrc": "@<ORG_NAME>:registry=https://npm.pkg.github.com/\n//npm.pkg.github.com/:_authToken=${NPM_TOKEN}",

Originally posted by @terrymun in #31253 (comment)

@rarkins rarkins added type:bug Bug fix of existing functionality priority-2-high Bugs impacting wide number of users or very important features core:config Related to config capabilities and presets labels Sep 10, 2024
@terrymun
Copy link

Thanks for looking into this @rarkins ❤️

@viceice
Copy link
Member

viceice commented Sep 10, 2024

we should deprecate npmToken and migrate it to a host rule

@btimo

This comment was marked as off-topic.

@rarkins

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core:config Related to config capabilities and presets priority-2-high Bugs impacting wide number of users or very important features type:bug Bug fix of existing functionality
Projects
None yet
Development

No branches or pull requests

5 participants