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

标签 github github-actions

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

- job: BuildFunctions
    
  steps:
  - ${{ each func in parameters.functionApps }}:
    - template: yaml/build-functionapps.yml
      parameters:
是否可以在 GitHub 操作中从另一个 yaml 文件调用 yaml 文件?

最佳答案

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

You can now specify containers, other composite actions (up to a depth of 9) and node actions in additional to the previously available run steps


节点 Action 可能指的是叶 Action ,即不调用任何其他 Action 的 Action 。
来源: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

[...]
复合运行 Action .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

旧限制:

What does composite run steps currently support?

For each run step in a composite action, we support:

  • name
  • id
  • run
  • env
  • shell
  • working-directory

In addition, we support mapping input and outputs throughout the action.

See docs for more info.

What does Composite Run Steps Not Support

We don't support setting conditionals, continue-on-error, timeout-minutes, "uses" [remark: i.e. using other actions], and secrets on individual steps within a composite action right now.

(Note: we do support these attributes being set in workflows for a step that uses a composite run steps action)


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

关于github - GitHub Actions 中的嵌套模板(从另一个 yaml 文件调用 yaml 文件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64055230/

相关文章:

git - 如何找到 Github 文件的 SHA blob

node.js - Passport 失败并出现 404 - GitHub 的 InternalOAuthError 为什么?

python - 如何使用 github 操作发布 pip 轮子

github - 为什么操作无法访问 secret ?

github - 发布 GitHub 页面时触发 GitHub 操作

git - 使用 GPG 签署 git 提交的问题

git - 如何获得 pull 请求的所有权?

github - 在 Github Actions 中获取当前推送的标签

azure - 如何配置 GitHub Actions 来构建依赖于私有(private)存储库的 Azure 静态 Web 应用程序?

php - 在 composer 依赖项中使用包 fork