fix(ci): 还原 backend.tf 为 shell heredoc,修复 Jinja2 内联 Python 导致的 YAML 语法错误
Python 内联脚本(python3 - <<'PYEOF'...PYEOF)的代码行从列 1 开始, 超出 YAML literal block 的缩进范围,导致整个 workflow 文件 YAML 解析失败, GitHub 丢失 workflow_dispatch 触发器。 还原为 shell heredoc(<<TFEOF,非引号,允许变量展开), 保留 force_path_style → use_path_style 升级。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4a6057d58b
commit
f636366699
35
.github/workflows/deploy-ai-workspace-iac.yaml
vendored
35
.github/workflows/deploy-ai-workspace-iac.yaml
vendored
@ -186,27 +186,20 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# endpoints 块只能在 HCL 里配置,无法通过 -backend-config flag 传递。
|
||||
# 用 Jinja2 渲染 backend.tf,避免 shell heredoc 的引号/转义问题。
|
||||
python3 - <<'PYEOF'
|
||||
import os, jinja2
|
||||
tmpl = jinja2.Template("""\
|
||||
terraform {
|
||||
backend "s3" {
|
||||
endpoints = { s3 = "{{ endpoint }}" }
|
||||
skip_credentials_validation = true
|
||||
skip_region_validation = true
|
||||
skip_requesting_account_id = true
|
||||
skip_metadata_api_check = true
|
||||
skip_s3_checksum = true
|
||||
use_path_style = true
|
||||
}
|
||||
}
|
||||
""")
|
||||
out = tmpl.render(endpoint=os.environ["TF_STATE_ENDPOINT"])
|
||||
with open("backend.tf", "w") as f:
|
||||
f.write(out)
|
||||
print("backend.tf rendered, endpoint=" + os.environ["TF_STATE_ENDPOINT"][:30] + "...")
|
||||
PYEOF
|
||||
# 用非引号 heredoc 将 endpoint URL 展开写入 backend.tf。
|
||||
cat > backend.tf << TFEOF
|
||||
terraform {
|
||||
backend "s3" {
|
||||
endpoints = { s3 = "${TF_STATE_ENDPOINT}" }
|
||||
skip_credentials_validation = true
|
||||
skip_region_validation = true
|
||||
skip_requesting_account_id = true
|
||||
skip_metadata_api_check = true
|
||||
skip_s3_checksum = true
|
||||
use_path_style = true
|
||||
}
|
||||
}
|
||||
TFEOF
|
||||
|
||||
- name: generate.py render (YAML -> 显式 HCL + tfvars)
|
||||
working-directory: ${{ env.VPS_ROOT }}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user