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

GitHub Actions:workflow_call输入转环境变量失败,SHA无法打印排查

GitHub Actions 被调用工作流中SHA无法打印的问题解决

问题根源

在other_workflow.yml的「Call python script」步骤里,你用了${{ github.event.inputs.commit-hash }}来设置环境变量,但这个变量仅在手动通过workflow_dispatch触发工作流时有效。当通过workflow_call被其他工作流调用时,输入参数需要通过${{ inputs.commit-hash }}访问,这就导致环境变量为空,脚本自然打印不出内容。

修复方法

修改other_workflow.yml中的「Call python script」步骤,将环境变量的引用替换为inputs.commit-hash:

- name: Call python script
  env:
    COMMIT_HASH: ${{ inputs.commit-hash }}
  run: python3 scripts/print_commit_hash.py

修复后效果

修改完成后:

  • 当通过call_other_workflow.yml触发时,Python脚本可以正常打印传入的短SHA
  • 手动通过workflow_dispatch触发other_workflow.yml时,inputs.commit-hash同样能获取到你手动输入的commit-hash,脚本也能正常运行

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 18:43:22