.npmrc
First, you need to configure your access in a local .npmrc
file. You can put this file in your source root folder.
always-auth = true
# First, set a different registry URL for your scope
@myscope:registry=https://company.jfrog.io/artifactory/api/npm/my-npm-registry/
# Then, for this scope, you need to set the token
//company.jfrog.io/artifactory/api/npm/my-npm-registry/:_auth = {{your token - see below}}
Token
You need to get the NPM Token from Artifactory (note it isn't your API Key.
- Get your Artifactory API Key from your Artifactory profile: https://company.jfrog.io/ui/admin/artifactory/user_profile
- Run the next command on your Linux terminal:
curl -u {{ ARTIFACTORY_USERNAME }}:{{ ARTIFACTORY_API_KEY }} https://company.jfrog.io/artifactory/api/npm/auth/
- You should receive this:
_auth = {{ YOUR_NPM_TOKEN }}
always-auth = true
- So now you can take this Token and put it in the
.npmrc
file above.
Github Actions
How to do all this in Github Actions?
- First, save your Jfrog username and API Key in Github Secrets:
JFROG_USER
& JFROG_PAT
.
- And you can add the next step to your workflow, after checkout and before
yarn/npm install
:
- name: npm token
run: |
echo "@myscope:registry=https://company.jfrog.io/artifactory/api/npm/my-npm-registry/" > .npmrc
echo "//company.jfrog.io/artifactory/api/npm/my-npm-registry/:$(curl -u ${{ secrets.JFROG_USER }}:${{ secrets.JFROG_PAT }} https://company.jfrog.io/artifactory/api/npm/auth/)" >> .npmrc