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
相关产品推荐
相关产品推荐

