新的GitHub操作在空文件夹中运行 [英] New GitHub actions run in empty folders

查看:115
本文介绍了新的GitHub操作在空文件夹中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用新的GitHub动作,以下工作流程的想法是在打开或同步pr时运行,它应该首先签出并安装依赖项,然后再运行少量的yarn脚本

I am working with new GitHub actions, idea of a workflow below is to run when pr is opened or synchronised, it should first check out and install dependencies and afterwards run few yarn scripts

name: PR to Master
on: 
  pull_request:
    branches:
    - master
jobs:
  # Synchronize or Opened
  synchronized_or_opened:
    name: Synchronize or Opened
    runs-on: ubuntu-latest
    steps:
    - uses: actions/bin/filter@master
      with:
        args: action 'opened|synchronize'
  # Add Labels
  add_labels:
    name: Add Labels
    runs-on: ubuntu-latest
    steps:
    - uses: actions/labeler@v2
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}
    needs: synchronized_or_opened
  # Checkout
  checkout:
    name: Checkout
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    needs: synchronized_or_opened
  # Install Dependencies
  install_dependencies:
    name: Install Dependencies
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [10.x]
    steps:
    - run: yarn dep:install-npm
    needs: checkout
  # Typecheck
  typecheck:
    name: Typecheck
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [10.x]
    steps:
    - run: yarn typecheck
    needs: install_dependencies
  # Prettier
  prettier:
    name: Prettier
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [10.x]
    steps:
    - run: yarn prettier
    needs: install_dependencies
  # ESLint
  eslint:
    name: ESlint
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [10.x]
    steps:
    - run: yarn eslint
    needs: install_dependencies
  # Danger
  danger:
    name: Danger
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [10.x]
    steps:
    - run: yarn danger
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    needs: install_dependencies

目前它已成功进入结帐阶段,但是一旦安装作业运行,我将收到以下错误消息

At the moment it successfully gets to a checkout stage, but once Install job is ran I get following error

错误无法在以下位置找到package.json文件 "/home/runner/work/myRepo/myRepo"

error Couldn't find a package.json file in "/home/runner/work/myRepo/myRepo"

通过此结帐判断失败还是我在错误的文件夹中?

Judging by this checkout either failed or I am in a wrong folder?

推荐答案

每个作业都在运行时指定的虚拟环境的新实例中运行.

Each job runs in a fresh instance of the virtual environment specified by runs-on.

根据我在这里看到的内容,您正在执行与其他人完全独立的结帐步骤.以这种方式进行操作不会以任何方式影响其他作业.实际上,应该在执行npm CLI命令的那些作业中 内定义它.

From what I can see here, you're doing the checkout step in a completely separate job from others. Doing it that way it does not affect other jobs in any way. It should actually be defined inside those jobs where your npm CLI commands are executed.

以下是您的其中一项工作的样子的示例:

Here's an example of how it would look like in one of your jobs:

jobs:
  # (...) Other jobs
  # Install Dependencies
  install_dependencies:
    name: Install Dependencies
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [10.x]
    steps:
    - uses: actions/checkout@master
    - run: yarn dep:install-npm
    needs: checkout
  # (...) Other jobs

GitHub启动器工作流程模板.

这篇关于新的GitHub操作在空文件夹中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆