Skip to content

Composite GitHub Action to run a command with Yarn. ✨

License

Notifications You must be signed in to change notification settings

Codecademy/run-on-yarn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

run-on-yarn

Composite GitHub Action to run a command with Yarn. ✨

Usage

This action will:

  1. Use actions/checkout and actions/setup-node to set up a yarn environment
  2. Use actions/cache to restore a cache based on the yarn.lock
  3. yarn install --frozen-lockfile if the folder didn't exist in the cache
  4. Run yarn ${{ inputs.command }}

Inputs

  • command: Command to run. Required.

Example

Simplest Usage

Running a single yarn test command on all commit pushes:

# .github/workflows/push.yml
name: Push CI

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: Codecademy/run-on-yarn@v1
        with:
          command: test

on: push

Matrix of Commands

Assuming the compile, format:verify, and test scripts exist in your package.json, this setup will run those commands in parallel as your Push CI job:

# .github/workflows/push.yml
name: Push CI

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: Codecademy/run-on-yarn@v1
        with:
          command: ${{ matrix.command }}

    strategy:
      fail-fast: false
      matrix:
        command: ['compile', 'format:verify', 'test']

on: push

Optional Inputs

Specifying a Node.js version

# .github/workflows/push.yml
name: Push CI

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: Codecademy/run-on-yarn@v1
        with:
          command: test
          node-version: 16

on: push

Specifying a different Github token to be used during checkout

Note: this is only necessary to override in certain extreme edge cases

# .github/workflows/push.yml
name: Push CI

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: Codecademy/run-on-yarn@v1
        with:
          command: test
          github-token: ${{ secrets.PERSONAL_TOKEN }}

on: push

Contribution Guidelines

We'd love to have you contribute! Check the issue tracker for issues labeled Accepting PRs to find bug fixes and feature requests the community can work on. If this is your first time working with this code, the Good First issue label indicates good introductory issues.

Please note that this project is released with a Contributor Covenant. By participating in this project you agree to abide by its terms. See CODE_OF_CONDUCT.md.

About

Composite GitHub Action to run a command with Yarn. ✨

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published