Skip to content

isabella232/action-npm-publish

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

action-npm-publish

Description

GitHub action to publish an npm module with a provided npm-token.

Usage

Pass your token to the action:

- name: Publish
  uses: MetaMask/action-npm-publish@v1
  with:
    npm-token: ${{ secrets.NPM_TOKEN }}

To publish an npm module whenever a release PR is merged, you could do something like this:

name: Publish to npm

on:
  pull_request:
    types: [closed]

jobs:
  cache-build:
    permissions:
      contents: write
    if: |
      github.event.pull_request.merged == true &&
      startsWith(github.event.pull_request.head.ref, 'release/')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Get Node.js version
        id: nvm
        run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
      - uses: actions/setup-node@v2
        with:
          node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
      - run: |
          yarn setup
          yarn build
      - uses: actions/cache@v2
        id: restore-build
        with:
          path: ./*
          key: ${{ github.sha }}

  publish-npm:
    # use a github actions environment
    evironment: publish
    runs-on: ubuntu-latest
    needs: cache-build
    steps:
      - uses: actions/cache@v2
        id: restore-build
        with:
          path: ./*
          key: ${{ github.sha }}
      - name: Publish
        uses: MetaMask/action-npm-publish@v1
        with:
          npm-token: ${{ secrets.NPM_TOKEN }}

About

GitHub Action to publish to NPM

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%