docs(lessons): 第 13 条反模式——CI YAML 内联 shell#10
PR #9 的元级教训沉淀。
反模式:在 CI YAML 里内联写多行 shell 脚本(带 &&/$()/for 循环)。
&&
$()
for
正模式:抽到独立 .sh 文件 + 明确 shebang(#!/bin/sh),本地可 sh -n/dash -n 静态检查。CI runner 的默认 shell 未必是 bash(CNB 是 dash,GitHub Actions 默认 bash 但可切 sh,GitLab 看配置)。
.sh
#!/bin/sh
sh -n
dash -n
防御位置:scripts/ci-wait-healthy.sh 作为模板。
scripts/ci-wait-healthy.sh
PR #9 的元级教训沉淀。
反模式:在 CI YAML 里内联写多行 shell 脚本(带
&&/$()/for循环)。正模式:抽到独立
.sh文件 + 明确 shebang(#!/bin/sh),本地可sh -n/dash -n静态检查。CI runner 的默认 shell 未必是 bash(CNB 是 dash,GitHub Actions 默认 bash 但可切 sh,GitLab 看配置)。防御位置:
scripts/ci-wait-healthy.sh作为模板。