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