繁体   English   中英

如何在 github 操作中的特定文件夹中运行我的 CI 步骤

[英]How do I run my CI steps in a specific folder in github action

我有一个带有react客户端的golang库。 我想为我的客户端使用 github 操作设置 CI。 React 客户client位于工作区的client文件夹内。 我编写了以下工作流程

name : Node.js CI

on: [push, pull_request]

jobs:

  build:
    name: build
    runs-on: ubuntu-latest
    steps:

    - uses: actions/checkout@v2 
      with:
        path: client
    - name: Set up Node.js
      uses: actions/setup-node@v1
      with:
        node-version: 12.x

    - run: yarn install

    - run: yarn build

但是在提交时显示以下错误

 Run yarn build1s
##[error]Process completed with exit code 1.
Run yarn build
yarn run v1.21.1
error Couldn't find a package.json file in "/home/runner/work/evential/evential"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
##[error]Process completed with exit code 1

片段

- uses: actions/checkout@v2 
      with:
        path: client

不会在client文件夹中运行以下步骤。

需要帮忙。 提前致谢。

您可以在run步骤中使用working-directory关键字。 请参阅此处的文档。

    - run: yarn install
      working-directory: client

    - run: yarn build
      working-directory: client

假设您的存储库结构如下所示:

.
├── README.md
├── client
│   └── ... # your source files
└── workflows
    └── example-ci.yml

您还可以使用以下方法为多个步骤设置默认工作目录:

defaults:
  run:
    working-directory: client # The working directory path

这样您就不需要为每个步骤指定它。 您还可以根据放置上述代码段的位置调整范围,用于:

  • 所有作业的所有步骤:将其放在工作流程的基础上。
  • 一项作业的所有步骤:将其放在工作流的作业属性中的作业中,以便适用于该作业的步骤。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM