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

tal*_*mir 3 workflow github github-actions

我有 3 个目录 ./github/workflows/

  • 短绒
  • 功能测试
  • 单元测试

在每个目录中,我都有多个工作流.yml文件,例如linters/codeQuality.yml

我的问题是,当发出拉取请求时,只会执行 root 中的工作流文件,而不是这些目录中的工作流文件。

我怎么解决这个问题?

riQ*_*iQQ 6

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

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

来源: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

[...]
Run Code Online (Sandbox Code Playgroud)

.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...]
Run Code Online (Sandbox Code Playgroud)