Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
target

GitHub Action

Use NPM Token

v1

Use NPM Token

target

Use NPM Token

Use an NPM token within an .npmrc file inside GitHub actions. Scoped packages are the primary use case

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Use NPM Token

uses: dkershner6/use-npm-token-action@v1

Learn more about this action in dkershner6/use-npm-token-action

Choose a version

Use NPM Token GitHub Action

Use an NPM token within an .npmrc file inside GitHub actions. Scoped packages are the primary use case.

WARNING

If you commit after this action runs, you will likely leak your NPM token secret in your newly created .npmrc file. Please use GitIgnore Parser to fully prevent this from occurring.

Usage

Inputs

key default required description
token n/a true An NPM token with whatever access is needed for your GitHub Action workflow
workspace ./ false The location of your Node workspace (needs to be a sibling of package.json)

Outputs

None

Example Workflow

on: pull_request

jobs:
  test-coverage:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Use NPM Token with organization read access
        uses: dkershner6/use-npm-token-action@v1
        with:
          token: "${{ secrets.NPMJS_READ }}"
          workspace: ./node

      - run: npm i # This will now work with scoped packages