File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 # 值为空的变量跳过,避免覆盖构建环境里已有的有效值
You can’t perform that action at this time.
0 commit comments