我将如何为子目录中的flutter项目设置github操作

发布于 2025-02-12 01:54:05 字数 412 浏览 0 评论 0原文

我正在为颤动中的CI/CD进行GitHub动作。该代码是主要存储库文件夹的子目录。我将如何在子目录中运行github动作。

我正在利用 subosito flutter Action

      - uses: subosito/flutter-action@v2
        with:
          channel: 'stable'
      - run: flutter pub get
      - run: flutter test
      - run: flutter build appbundle

I am working on github actions for ci/cd in flutter. The code is a subdirectory to the main repository folder. How would I run the github action in the subdirectory.

I am making use of the subosito flutter action

      - uses: subosito/flutter-action@v2
        with:
          channel: 'stable'
      - run: flutter pub get
      - run: flutter test
      - run: flutter build appbundle

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜吻♂芭芘 2025-02-19 01:54:05

解决方案1

​​ 接受一个名为Working-Directory的关键字。只需将其设置为子目录,就可以了。这将是这样的:

      - run: flutter pub get
        working-directory: your_subdirectory
      - run: flutter test
        working-directory: your_subdirectory
      - run: flutter build appbundle
        working-directory: your_subdirectory

解决方案2

也可以将其设置为每个作业(

jobs:
  job1:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: your_subdirectory

jobs

。 /actions/lust-workflows/workflow-syntax-for-github-actions#defaultsrun“ rel =“ noreferrer”> defaults.run 设置默认目录全局(用于所有作业)作为您期望的子目录。这样,您将删除大量重复。

defaults:
  run:
    working-directory: your_subdirectory

Solution 1

run accepts a keyword named working-directory. Just set it to the subdirectory and you're good to go. It's going to be something like this:

      - run: flutter pub get
        working-directory: your_subdirectory
      - run: flutter test
        working-directory: your_subdirectory
      - run: flutter build appbundle
        working-directory: your_subdirectory

Solution 2

It's also possible to set it per job (jobs.<job_id>.defaults.run) like so:

jobs:
  job1:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: your_subdirectory

Solution 3

You can also use defaults.run to set the default directory globally (for all jobs) as the subdirectory you expect. This way you'd remove a lot of repetition.

defaults:
  run:
    working-directory: your_subdirectory
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文