Skip to content

Warning

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

NPM Worker

Actions
An action to init and manage node modules on your repo
1.0.0
Star (0)

Github Action   Support Mudlabs

NPM Worker

Manage node packages on your Github Action repository.

Table of Contents


Requirements

Requirement Description
npmworker.config.yaml You must include the YAML configuration file in your repository. If you do not pass its path to the config key in your workflow, the action will look for it in the directory of the workflow that triggered the action, then in .github, and finally in root (./).

Usage

1. Implement a Workflow for your action

  • It's a good idea to ensure the action only runs when a change to npmworker.config.yaml is made.
# ./.github/workflows/npmworker.yaml

name: NPM Worker
on:
  push:
    branches:
      - master:
    paths:
      - .github/workflows/npmworker.config.yaml
jobs:
  npm:
    runs-on: ubuntu-latest
    name: NPM Worker
    steps:
      - uses: actions/checkout@v2
      - name: Worker
        uses: mudlabs/npm-worker@1.0.0
        with:
          # OPTIONAL: Provide a PAT for the repository, so the
          # action can log activity to an issue.
          # Default: github.token
          toke: ${{ secrets.GITHUB_TOKEN }}
          # OPTIONAL: Provide a path within your repository to
          # the YAML configuration file.
          # If not provided the action will attempt to find it
          # before failing.
          config: ./path/to/npmworker.config.yaml

2. Now add the configuration file

  • If you want to remove a package it's not enough to remove it from the install array, you need to add it to the uninstall array.
Prop Description Default
clean Specifies the action should edit the configuration file apon execution. This way every time you update the file it's a clean list of commands. Only the install, update, and uninstall arrays will be emptied, and they will be regardless of the package execution outcome. false
issue You may provide an issue number to track activity. If set this action will post comments to the issue detailing what has changed, whenever it runs.
path Specifies a path from your repository root, where you would like node_modules located. ./
install An array of npm packages you want installed.
update An array of packages to update, or install if they are not installed.
uninstall An array of packages to uninstall.
# Example Configuration.
# ./.github/workflows/npmworker.config.yaml

clean: true
issue: 1
path: ./dis
install:
  - "@actions/github"
  - unirest
update:
  - cardinal-direction
uninstall:
  - node-fetch

Output

Prop Description
activity A markdown flavourd description of the activity performed by the action. If an issue number is specified within the configuration file, this is the comment sent to that issue.

Notes

  • If no package.json file is located at path, the action will create one using npm init -y.
  • If you want the node_modules and packages to persist on your repository you will need to commit the changes. I recommend using the Add and Commit action for this.
  • You can not chain executions. Each array item is checked for, and broken at any instance of &&.
  • Each array item is executed as npm x item (i.e. npm install unirest).

NPM Worker is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

An action to init and manage node modules on your repo
1.0.0

NPM Worker is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.