GitHub Actions-如何在子目录中构建项目

时间:2019-09-05 13:29:40

标签: github-actions

我正在使用GitHub Actions构建我的项目,但是我的Dart项目在存储库的子目录中。 Action脚本找不到我的pubspec.yaml并获取依赖项。

如何指向GitHub Action在存储库的子目录中查找源代码?

. (root of my GitHub repository)
└── dart_project
    ├── pubspec.yaml   <-- Git Hub action must point to this sub-dir
└── node_project
    ├── packages.json

这是我得到的错误:

Could not find a file named "pubspec.yaml" in "/__w/<my_project_path>".
##[error]Process completed with exit code 66.

这是GitHub自动生成的dart.yml文件。

name: Dart CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    container:
      image:  google/dart:latest

    steps:
    - uses: actions/checkout@v1
    - name: Install dependencies
      run: pub get
    - name: Run tests
      run: pub run test

enter image description here

1 个答案:

答案 0 :(得分:5)

如果我了解您的需求,那么您需要执行pub步骤,就好像您先完成cd dart_project一样,对吗?将working-directory参数添加到您的步骤中:

steps:
- uses: actions/checkout@v1
- name: Install dependencies
  run: pub get
  working-directory: dart_project
- name: Run tests
  run: pub run test
  working-directory: dart_project

我相信这应该是您所需要的。