使用 Git 子模块
编辑页面
了解如何配置 EAS Build 以使用 git 子模块。
For the complete documentation index, see llms.txt. Use this Use this file to discover all available pages.
使用默认的 Version Control Systems(VCS)工作流时,您的工作目录内容会按原样上传到 EAS Build,包括 Git 子模块的内容。但是,如果您在 CI 上构建,或在 eas.json 中将 cli.requireCommit 设置为 true,或者子模块位于私有仓库中,则需要先对其进行初始化,以避免上传空目录。
子模块初始化
要在 EAS Build 构建器上初始化子模块:
1
创建一个包含已 base64 编码的私有 SSH 密钥的 secret,该密钥需要有访问子模块仓库的权限。
2
添加一个用于检出这些子模块的 eas-build-pre-install npm hook,例如:
eas-build-pre-install.sh
#!/usr/bin/env bash mkdir -p ~/.ssh # 在打包过程中会丢失真实的 origin URL,因此如果你的 # 子模块在 .gitmodules 中使用了相对 URL,那么你 # 需要通过以下方式恢复它: # # git remote set-url origin git@github.com:example/repo.git # 从环境变量中恢复私钥并生成公钥 umask 0177 echo "$SSH_KEY_BASE64" | base64 -d > ~/.ssh/id_rsa umask 0022 ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub # 将你的 git 提供商添加到已知主机列表中 ssh-keyscan github.com >> ~/.ssh/known_hosts git submodule update --init