我的 git 存储库中有一个子模块,我的目录结构如下:
app
-- folder1
-- folder2
-- submodule @5855
我已使用自动部署服务在 AWS 上部署了我的代码。
现在,在服务器上,我的父目录中有代码,但子模块目录为空。
Q1)如何获取子模块中的数据。我在服务器上的存储库不是 git 存储库。我需要先将其转换为 git repo 然后运行submodule
命令来获取它?
Q2)如何自动化子模块部署?
Thanks
编辑:Codebuild 现在有一个“子模块”标志https://docs.aws.amazon.com/codebuild/latest/APIReference/API_GitSubmodulesConfig.html https://docs.aws.amazon.com/codebuild/latest/APIReference/API_GitSubmodulesConfig.html
这对我有用
我们将重新初始化 git 存储库,然后在部署的构建阶段触发子模块克隆,本质上是修补以支持 codepipeline / codebuild 中的子模块
- 为您的 github 帐户生成新的 SSH 密钥,如果使用组织,您可能需要创建部署用户
- 使用以下命令将此 ssh 密钥存储在您的 aws 参数存储中
aws ssm put-parameter --name build_ssh_key --type String --value "$(cat id_rsa)"
理想情况下使用 SecureString 而不是 String,但我遵循的指南仅使用字符串,因此我不确定命令行是否需要任何额外参数
- 进入 IAM 并授予您的 CodePipeline 用户对 paramstore 的读取权限,我刚刚授予对 SSM 的读取权限
然后使您的 buildspec.yml 如下所示:
version: 0.2
env:
parameter-store:
build_ssh_key: "build_ssh_key"
phases:
install:
commands:
- mkdir -p ~/.ssh
- echo "$build_ssh_key" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keygen -F github.com || ssh-keyscan github.com >>~/.ssh/known_hosts
- git config --global url."[email protected] /cdn-cgi/l/email-protection:".insteadOf "https://github.com/"
- git init
- git remote add origin <Your Repo url here using the git protocol>
- git fetch
- git checkout -t origin/master
- git submodule init
- git submodule update --recursive
build:
commands:
- echo '...replace with real build commands...'
artifacts:
files:
- '**/*'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)