如何使用 Yarn 创建 GitHub 动作以 运行 Jest 测试?

How do I create a GitHub Action to run Jest tests with Yarn?

我使用 Yarn to run my Jest 测试。

package.json

{
  "scripts": {
    "test": "jest"
  }
}
yarn test

我想用 NPM 创建 GitHub action to run my tests when I merge commits in GitHub. The Node Starter Workflow 运行s 测试。但我想 运行 他们用 Yarn。

如何为 运行 我的测试创建一个动作?

使用 Node Starter Workflow 但将 NPM 部分替换为 Yarn 命令。例如:

name: Node CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x, 12.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: yarn install
    - run: yarn test