Using npm set config _auth with a GitHub Secret fails

383 Views Asked by At

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

There are 1 best solutions below

0
On

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