GitHub Actions 中的嵌套模板(从另一个 yaml 文件调用 yaml 文件)

use*_*060 4 github github-actions

GitHub 操作是否支持嵌套模板?例如,以下是 Azure Pipeline yaml 的示例,它调用另一个 yaml 文件:

- job: BuildFunctions
    
  steps:
  - ${{ each func in parameters.functionApps }}:
    - template: yaml/build-functionapps.yml
      parameters:
Run Code Online (Sandbox Code Playgroud)

是否可以在 GitHub 操作中从另一个 yaml 文件调用 yaml 文件?

riQ*_*iQQ 6

您可以使用复合运行步骤操作。这些是在 YAML(文档)中单独定义的操作。

除了先前可用的run步骤之外,您现在可以指定容器、其他复合动作(最多 9 个深度)和节点动作

节点动作可能指的是叶动作,即不调用任何其他动作的动作。

来源:https : //github.com/actions/runner/issues/646#issuecomment-901336347

工作流程

[...]

jobs:
  job:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: ./.github/workflows/composite-action

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

复合运行步骤操作
.github/workflows/composite-action/action.yml(与工作流相同的存储库)

name: "My composite action"
description: "Checks out the repository and does something"
runs:
  using: "composite"
  steps:
  - uses: actions/checkout@v2
  - uses: actions/setup-node@v2
    with:
      node-version: 12
  - run: npm test
    shell: bash
  - run: |
      echo "Executing action"
    shell: bash
Run Code Online (Sandbox Code Playgroud)

旧限制:

复合运行步骤目前支持什么?

对于复合动作中的每个运行步骤,我们支持:

  • 姓名
  • ID
  • 环境
  • 贝壳
  • 工作目录

此外,我们支持在整个动作中映射输入和输出。

有关更多信息,请参阅文档

复合运行步骤不支持什么

我们现在不支持设置条件、continue-on-error、timeout-minutes、“uses”[备注:即使用其他操作],以及复合操作中各个步骤的秘密。

(注意:我们确实支持在工作流中为使用复合运行步骤操作的步骤设置这些属性)

来源:https : //github.com/actions/runner/issues/646


Mei*_*wjn 0

不它不是。我在 GitHub 论坛上问了完全相同的问题:

是否可以通过工作流语法/YML 中的代码来创建/发布没有 Docker 或 JS 的操作?

正如文档中提到的:目前,actions 类型只列出了 Docker 容器和 JavaScript,因此没有这样的功能来实现您的要求。来源:https://github.community/t/how-to-create-ready-to-use-action-without-docker-js/124889/2

这将简化为系统管理员用户创建模板的过程。