Skip to content
chevrons-right

GitHub Action

Setup Yarn Berry

v2.0.0 Latest version

Setup Yarn Berry

chevrons-right

Setup Yarn Berry

Install Node.js dependencies using Yarn with cache support

Installation

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

              

- name: Setup Yarn Berry

uses: threeal/[email protected]

Learn more about this action in threeal/setup-yarn-action

Choose a version

Setup Yarn Berry Action

The Setup Yarn Berry Action is a GitHub action designed to set up the Yarn package manager in the GitHub workflows of your Node.js projects. This action sets up Yarn to a specified version and installs dependencies for the current Node.js project with cache support. Cache support provides fast setup for Node.js projects by using dependencies installed from previous runs.

This action currently only supports the berry version of Yarn (Yarn 2+). If your project still uses the classic version of Yarn, it is suggested to migrate to the berry version. Refer to this for the migration guide.

Key Features

The Setup Yarn Berry Action offers the following key features:

  • Sets up Yarn to a specified version.
  • Installs dependencies for the current Node.js project with cache support.

Available Inputs

Here are the available input parameters for the Setup Yarn Berry Action:

Name Type Description
version String Specifies the version of Yarn to set up using this action. The specified version can be a tag (e.g., stable), a semver range (e.g., 4.x), or a semver version (e.g., 4.1.0). If not specified, it uses the default Yarn version.
cache Boolean Indicates whether to enable caching during Yarn installation. It defaults to true.

Example Usage

Here's a basic example demonstrating how to utilize the Setup Yarn Berry Action to set up the default version of Yarn and install dependencies for the current Node.js project in the GitHub workflow:

name: Node.js CI
on:
  push:
jobs:
  build:
    name: Build Project
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/[email protected]

      - name: Setup Yarn
        uses: threeal/[email protected]

      # Add more steps as needed for your workflow

Specifying Yarn Version

By default, this action will set up Yarn to the default version specified by the current Node.js project. However, you can override it by specifying it in the version input parameter as shown below:

- name: Setup Latest Yarn
  uses: threeal/[email protected]
  with:
    version: latest

Refer to this for more information on the available versions that can be set up by this action.

Disabling Caching

By default, caching is always enabled when installing dependencies of the current Node.js project. To disable it, set the cache input parameter to false as shown below:

- name: Setup Yarn Without Caching
  uses: threeal/[email protected]
  with:
    cache: false

License

This project is licensed under the terms of the MIT License.

Copyright © 2023-2024 Alfi Maulana