使用 npm 设置配置 _auth 与 GitHub 秘钥失败。

huangapple go评论44阅读模式
英文:

Using npm set config _auth with a GitHub Secret fails

问题

以下是您要翻译的内容:

"run"部分中的以下npm配置设置在我的GitHub操作中不起作用。

npm config set //my.registry.io/npm/:_auth {{ secret.NPM_ACCESSTOKEN }}

我知道secret.NPM_ACCESSTOKEN的值是正确的,我已经能够通过另一种方法进行验证。

但是我需要使用npm config set _auth value方法,而不是使用".npmrc"。

例如,我尝试了各种方法:

token=$(echo "$(curl -u "$UsernameKey" $Uri)" | extract_token()
npm config set _auth $token  

这将返回与存储在GitHub Secrets中的值完全相同,并且可以成功工作。但这意味着我需要使用curl进行额外的请求。

英文:

The following npm config set, in my "run" section does not work in my GitHub action.

npm config set //my.registry.io/npm/:_auth {{ secret.NPM_ACCESSTOKEN }}

I know the value of secret.NPM_ACCESSTOKEN is correct, I've been able to verify with an alternative method.

However I need to use the npm config set _auth value method instead of using a ".npmrc".

I've tried a variety of methods for example:

token=$(echo "$(curl -u "$UsernameKey" $Uri)" | extract_token()
npm config set _auth $token  

This returns me exactly the same value as the one stored in GH secrets and works successfully. However means I'm making an additional request with the curl.

答案1

得分: 1

After double checking all the secrets and passing them into an env (via GitHub) action. The following was the working solution.

Note that I did provide single quotes around the env.NPM_ACCESSTOKEN and _auth instead _authToken worked for me. (thanks @azeem)

npm config set //my.jrog.io/npm/:_auth '{{ env.NPM_ACCESSTOKEN }}'
npm config set strict-ssl false
npm config set email ${{ env.NPM_USERNAME }}@email.com
npm config set registry https://my.jrog.io/npm/npm

英文:

After double checking all the secrets and passing them into an env (via GitHub) action. The following was the working solution.

Note that I did provide single quotes around the env.NPM_ACCESSTOKEN and _auth instead _authToken worked for me. (thanks @azeem)

npm config set //my.jrog.io/npm/:_auth '${{ env.NPM_ACCESSTOKEN }}'
npm config set strict-ssl false
npm config set email ${{ env.NPM_USERNAME }}@email.com
npm config set registry https://my.jrog.io/npm/npm

huangapple
  • 本文由 发表于 2023年6月26日 16:11:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76554756.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定