You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将列表作为输入传递给GitHub Actions可复用工作流?

解决GitHub Actions可复用工作流传递列表类型运行器的问题

要实现传递列表类型的运行器参数,只需调整可复用工作流的输入类型为数组(array),具体操作如下:

1. 修改可复用工作流的输入定义

将原工作流中runner输入的类型从string改为array,适配多标签运行器的数组格式:

name: "Reusable workflow which need to pass on multiple runners"
on:
  workflow_call:
    inputs:
      runner:
        required: true
        type: array  # 变更为数组类型
jobs:
  build:
    name: Build image
    runs-on: ${{ inputs.runner }}

2. 在调用工作流中传递数组参数

此时即可正常传递多标签运行器的数组参数,单个运行器也可以用单元素数组的形式传递:

name: "e2e: calling workflow"
on:
  push:
  pull_request:
    branches:
      - master
jobs:
  call-workflow-passing-data:
    uses: ./.github/workflows/e2e-common.yml
    with:
      runner: [self-hosted, v3]  # 多标签运行器数组
      # 单个运行器可写成:runner: ["ubuntu-22.04"]

内容的提问来源于stack exchange,提问作者Fabrice Jammes

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 08:43:16