diff --git a/.github/workflows/deploy-ai-workspace-iac.yaml b/.github/workflows/deploy-ai-workspace-iac.yaml index dc4f611..3311867 100644 --- a/.github/workflows/deploy-ai-workspace-iac.yaml +++ b/.github/workflows/deploy-ai-workspace-iac.yaml @@ -153,11 +153,6 @@ jobs: fi [ "$missing" -eq 0 ] || { echo "::error::必需机密缺失,终止 provision"; exit 1; } - - name: Checkout xworkspace-console (scripts) - uses: actions/checkout@v4 - with: - path: xw-console - - name: Checkout iac_modules uses: actions/checkout@v4 with: @@ -188,7 +183,7 @@ jobs: working-directory: ${{ env.ENV_DIR }} env: TF_STATE_ENDPOINT: ${{ steps.vault.outputs.TF_STATE_ENDPOINT }} - run: python3 $GITHUB_WORKSPACE/xw-console/scripts/render_backend_tf.py backend.tf + run: python3 $GITHUB_WORKSPACE/${{ env.VPS_ROOT }}/scripts/render_backend_tf.py backend.tf - name: generate.py render (YAML -> 显式 HCL + tfvars) working-directory: ${{ env.VPS_ROOT }} diff --git a/CLAUDE.md b/CLAUDE.md index b38a4cb..722aec6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -28,19 +28,16 @@ run: | **正确做法:外置脚本,workflow 只做调用。** ```yaml -# ✅ 正确 — 外置 Python 脚本 -- name: Checkout xworkspace-console (scripts) - uses: actions/checkout@v4 - with: - path: xw-console - +# ✅ 正确 — 外置 Python 脚本(放在 infra repo,通过已有 checkout 引用) - name: Configure remote backend env: TF_STATE_ENDPOINT: ${{ steps.vault.outputs.TF_STATE_ENDPOINT }} - run: python3 $GITHUB_WORKSPACE/xw-console/scripts/render_backend_tf.py backend.tf + run: python3 $GITHUB_WORKSPACE/${{ env.VPS_ROOT }}/scripts/render_backend_tf.py backend.tf ``` -脚本存放在 `scripts/` 目录,命名规范 `动词_名词.py` 或 `动词-名词.sh`。 +渲染脚本存放在 `ai-workspace-infra/iac_modules/terraform-hcl-standard/vultr-vps/scripts/`, +通过 workflow 内已有的 `Checkout iac_modules` 步骤引用,无需额外 self-checkout。 +workflow 内的 `run:` 块调用外置脚本,命名规范 `动词_名词.py` 或 `动词-名词.sh`。 ### 其他规范 diff --git a/scripts/render_backend_tf.py b/scripts/render_backend_tf.py deleted file mode 100644 index 84c228a..0000000 --- a/scripts/render_backend_tf.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python3 -""" -渲染 Terraform S3 backend 配置文件(backend.tf)。 - -用法: - TF_STATE_ENDPOINT=https://... python3 render_backend_tf.py [output_path] - -默认输出到当前目录的 backend.tf(terraform init 的 working-directory 里执行)。 -""" -import os -import sys - -endpoint = os.environ.get("TF_STATE_ENDPOINT", "") -if not endpoint: - print("ERROR: TF_STATE_ENDPOINT is not set", file=sys.stderr) - sys.exit(1) - -output = sys.argv[1] if len(sys.argv) > 1 else "backend.tf" - -content = f"""\ -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 - }} -}} -""" - -with open(output, "w") as f: - f.write(content) - -print(f"backend.tf written to {output}") -print(f" endpoint = {endpoint[:40]}...")