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

Github Action复用工作流无法传递字符串参数求助

Github Action复用工作流参数传递失败的问题解决

问题出在复用工作流中获取参数的方式错误:你在reusable-workflow.yml里使用github.event.inputs.destination来获取参数,但对于通过workflow_call触发的复用工作流,传入的参数需要通过inputs上下文直接访问,而非github.event.inputs。

github.event.inputs仅适用于workflow_dispatch、pull_request这类直接触发的事件自带的输入参数,而复用工作流通过with传递的参数会被注入到inputs上下文,所以正确的获取方式是inputs.destination。

修正后的reusable-workflow.yml代码如下:

name: Print destination
on:
  workflow_call:
    inputs:
      destination:
        type: string
        required: true
jobs:
  print_destination:
    runs-on: [ self-hosted ]
    steps:
      - name: Print inputs
        run: |
          echo "destination:" ${{ inputs.destination }}

修改后重新执行,就能正确输出myword了。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 17:22:39