From f01641d3fe914ee24a4d2c9a40eae3cb5297a92c Mon Sep 17 00:00:00 2001 From: szhhwh <3116737282@qq.com> Date: Fri, 2 May 2025 20:51:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8D=86=E6=A3=98=E9=B8=9F?= =?UTF-8?q?=E5=AE=98=E6=96=B9=E4=BB=93=E5=BA=93=E5=85=8B=E9=9A=86=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.tf | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 1e25719..5712bac 100644 --- a/main.tf +++ b/main.tf @@ -14,6 +14,33 @@ locals { image_name = "coder-nodejs-base:latest" } +data "coder_parameter" "clone_reference" { + name = "克隆参考文档站点" + type = "bool" + description = "是否克隆荆棘鸟参考文档站点" + mutable = true + default = "true" + icon = "/emojis/1f4d6.png" +} + +data "coder_parameter" "clone_spbook" { + name = "克隆高三特刊站点" + type = "bool" + description = "是否克隆荆棘鸟高三特刊站点" + mutable = true + default = "false" + icon = "/emojis/1f4da.png" +} + +data "coder_parameter" "clone_main" { + name = "克隆主站点" + type = "bool" + description = "是否克隆荆棘鸟主站点" + mutable = true + default = "false" + icon = "/emojis/1f3e0.png" +} + variable "docker_socket" { default = "" description = "(Optional) Docker socket URI" @@ -75,8 +102,44 @@ EOF cat ~/.ssh/git.pub # 添加 git 全局配置 - git config set --global user.name "${data.coder_workspace_owner.me.name}" - git config set --global user.email "${data.coder_workspace_owner.me.email}" + git config --global user.name "${data.coder_workspace_owner.me.name}" + git config --global user.email "${data.coder_workspace_owner.me.email}" + + cd /home/coder/jingjiniao + + # 拉取仓库 + if [ "${data.coder_parameter.clone_reference.value}" = "true" ]; then + echo "正在克隆 reference 仓库..." + git clone https://gitea.lionhao.top/jjnwxs/jingji_reference.git + echo "reference 仓库克隆完成" + # 修改远程仓库地址为SSH + cd jingji_reference + git remote set-url origin git@ssh.lionhao.top:jjnwxs/jingji_reference.git + echo "reference 仓库远程地址已更新为SSH" + cd .. + fi + + if [ "${data.coder_parameter.clone_spbook.value}" = "true" ]; then + echo "正在克隆 spbook 仓库..." + git clone https://gitea.lionhao.top/jjnwxs/jingji_spbook.git + echo "spbook 仓库克隆完成" + # 修改远程仓库地址为SSH + cd jingji_spbook + git remote set-url origin git@ssh.lionhao.top:jjnwxs/jingji_spbook.git + echo "spbook 仓库远程地址已更新为SSH" + cd .. + fi + + if [ "${data.coder_parameter.clone_main.value}" = "true" ]; then + echo "正在克隆 main 仓库..." + git clone https://gitea.lionhao.top/jjnwxs/jingji_main.git + echo "main 仓库克隆完成" + # 修改远程仓库地址为SSH + cd jingji_main + git remote set-url origin git@ssh.lionhao.top:jjnwxs/jingji_main.git + echo "main 仓库远程地址已更新为SSH" + cd .. + fi touch ~/.init_done fi