使用 Git 子模块
了解如何配置 EAS Build 以使用 git 子模块。
在使用默认的版本控制系统(VCS)工作流程时,工作目录的内容会按原样上传到 EAS Build,包括 Git 子模块的内容。但是,如果你在 CI 上构建,或者在 eas.json 中将 cli.requireCommit 设置为 true,或者子模块位于私有仓库中,你需要初始化它以避免上传空目录。
🌐 When using the default Version Control Systems (VCS) workflow, the content of your working directory is uploaded to EAS Build as it is, including the content of Git submodules. However, if you are building on CI or have cli.requireCommit set to true in eas.json or have a submodule in a private repository, you will need to initialize it to avoid uploading empty directories.
子模块初始化
🌐 Submodules initialization
要在 EAS Build 构建器上初始化子模块:
🌐 To initialize a submodule on EAS Build builder:
1
2
添加一个 eas-build-pre-install npm 钩子 来检出这些子模块,例如:
🌐 Add an eas-build-pre-install npm hook to check out those submodules, for example:
#!/usr/bin/env bash mkdir -p ~/.ssh # Real origin URL is lost during the packaging process, so if your # submodules are defined using relative urls in .gitmodules then # you need to restore it with: # # git remote set-url origin git@github.com:example/repo.git # restore private key from env variable and generate public key umask 0177 echo "$SSH_KEY_BASE64" | base64 -d > ~/.ssh/id_rsa umask 0022 ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub # add your git provider to the list of known hosts ssh-keyscan github.com >> ~/.ssh/known_hosts git submodule update --init