簡體   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