您可以使用复合运行步骤操作。这些是仅在 YAML 中定义的操作(文档 https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action#creating-an-action-metadata-file).
除了以前可用的操作之外,您现在还可以指定容器、其他复合操作(最多 9 个深度)和节点操作run
steps
节点动作可能指的是叶操作,即不调用任何其他操作的操作。
Source: https://github.com/actions/runner/issues/646#issuecomment-901336347 https://github.com/actions/runner/issues/646#issuecomment-901336347
Workflow
[...]
jobs:
job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/workflows/composite-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
旧的限制:
复合运行步骤当前支持什么?
对于复合操作中的每个运行步骤,我们支持:
- name
- id
- run
- env
- shell
- 工作目录
此外,我们支持在整个操作过程中映射输入和输出。
See docs https://docs.github.com/en/actions/creating-actions/about-actions#composite-run-steps-actions了解更多信息。
复合运行步骤不支持什么
我们现在不支持在复合操作中的各个步骤上设置条件、错误继续、超时分钟、“使用”[备注:即使用其他操作]以及秘密。
(注意:我们确实支持在工作流程中为使用复合运行步骤操作的步骤设置这些属性)
Source: https://github.com/actions/runner/issues/646 https://github.com/actions/runner/issues/646