如何从子目录运行多个GitHub Actions工作流程

4

我在./github/workflows/目录下有3个文件夹:

  • linters
  • functionalTests
  • unitTests

每个文件夹内都有多个工作流程的.yml文件。例如:linters/codeQuality.yml

我的问题是,当提交一个拉取请求时,只有根目录中的工作流程文件会被执行,而不是这些文件夹中的工作流程文件。

我该如何解决这个问题?


1
你找到解决方法了吗?我也在想同样的问题。 - IgorGanapolsky
1个回答

10

你不能从子目录运行工作流:

你必须将工作流文件存储在仓库的 .github/workflows 目录中。

Source: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#about-yaml-syntax-for-workflows


你可以使用组合运行步骤操作(文档)。 .github/workflows/workflow.yaml
[...]

jobs:
  myJob:
    name: My Job
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - uses: ./.github/workflows/linters/codeQuality

[...]

.github/workflows/linters/codeQuality/action.yaml

name: "My composite action"
description: "Checks out the repository and does something"
runs:
  using: "composite"
  steps: 
  - run: |
      echo "Doing something"

  [other steps...]

1
好的。我能否从主工作流文件中调用工作流程? - talhaamir
请查看 https://stackoverflow.com/a/63710170 和 https://dev59.com/RLzpa4cB1Zd3GeqPUe9i#63606663。 - riQQ
1
这并没有帮助我。 - talhaamir
我们如何知道哪个工作流以什么顺序运行? - IgorGanapolsky

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接