Skip to content
play

GitHub Action

NodeJS with cache

v0.3.0 Latest version

NodeJS with cache

play

NodeJS with cache

Setup requested NodeJS version with managed modules caching

Installation

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

              

- name: NodeJS with cache

uses: Drafteame/[email protected]

Learn more about this action in Drafteame/node-cache-action

Choose a version

node-cache-action

Composite GitHub Action combining actions/setup-node with actions/cache for node_modules caching.

Configuration

- name: ejson action
  uses: Drafteame/node-cache-action-action@main
  with:
    node-version: '20' # nodejs version
    working-directory: cmd # path where the npm install command is run.
    cache-key-suffix: suffix # Optional cache key suffix

Outputs

Output Description
cache-path NodeJS modules cache path (node_modules).
cache-key Cache key holding module cache paths.

Usage

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
        - name: Checkout Repository
        uses: actions/checkout@v4

        - name: ⚙️ Setup NodeJS with cache
        uses: Drafteame/node-cache-action
        with:
            node-version: '20'
            working-directory: cmd/${{ github.event.inputs.service }}
            cache-key-suffix: ${{ github.event.inputs.stage }}
            
      - name: Install SLS dependencies
        working-directory: cmd/${{ github.event.inputs.service }}
        run: npm install