Skip to content

Commit 567d22e

Browse files
linyuan.yangclaude
andcommitted
build-env 支持经 secrets 传入(reusable workflow 的 with: 不允许引用 secrets 上下文)
Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent 3faea76 commit 567d22e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

.github/workflows/tauri-desktop-release.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ on:
4242
required: false
4343
type: boolean
4444
default: false
45-
# 构建期注入到二进制的环境变量,多行 KEY=VALUE(调用方用 secrets 拼装)。
45+
# 构建期注入到二进制的环境变量,多行 KEY=VALUE(非敏感值可直接写)。
46+
# 敏感值放调用方仓库的 BUILD_ENV_SECRETS secret(同为多行 KEY=VALUE),
47+
# 调用方使用 secrets: inherit 即可自动透传,此处不声明任何 secrets 输入。
4648
# 仅透传给构建步骤,值为空的行会被跳过;不使用该机制的项目无需配置。
4749
build-env:
4850
required: false
@@ -126,12 +128,13 @@ jobs:
126128
fi
127129
128130
- name: Apply build env
129-
if: inputs.build-env != ''
131+
if: inputs.build-env != '' || secrets.BUILD_ENV_SECRETS != ''
130132
shell: bash
131133
env:
132134
BUILD_ENV: ${{ inputs.build-env }}
135+
BUILD_ENV_SECRETS: ${{ secrets.BUILD_ENV_SECRETS }}
133136
run: |
134-
printf '%s\n' "$BUILD_ENV" | while IFS= read -r line; do
137+
printf '%s\n%s\n' "$BUILD_ENV" "$BUILD_ENV_SECRETS" | while IFS= read -r line; do
135138
[ -z "$line" ] && continue
136139
case "$line" in *=*) ;; *) continue ;; esac
137140
# 值为空的变量跳过,避免覆盖构建环境里已有的有效值

0 commit comments

Comments
 (0)