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

GitHub Action调用可复用工作流时secrets插值报语法错误如何解决

问题原因

报错的核心原因是调用可复用工作流时,涉密参数传参方式错误。GitHub Actions规定,with字段仅用于传递非涉密的普通入参,涉密的secrets需要使用独立的secrets字段传递,你之前将secrets引用放在了with字段下,所以会触发无法识别secrets的语法错误。

修正后的调用方工作流配置

name: Build workflow
on:
  push:
    branches:
      - dev
      - main
  pull_request:
    types:
      - opened
      - edited
      - reopened
    branches:
      - main
      - dev

jobs:
  # reference: https://docs.github.com/en/actions/learn-github-actions/reusing-workflows#example-caller-workflow
  org-checks:
    uses: repo/.github/workflows/main_workflow.yml@main
    # 替换原有的with字段为secrets字段传递涉密参数
    secrets:
      SECRET_1: ${{ secrets.SECRET_1 }}
      SECRET_2: ${{ secrets.SECRET_2 }}

可选简化写法

如果你需要将当前仓库的所有secrets全部透传给可复用工作流,可以直接简写为:

jobs:
  org-checks:
    uses: repo/.github/workflows/main_workflow.yml@main
    secrets: inherit

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.30 19:24:03