git - 如何在 Github Actions 中获取子模块的最新提交文件,以便在构建过程中使用它?
问题描述
最近我创建了一个依赖于来自另一个存储库的数据的 React 网站。所以我在我自己的 Github 存储库中添加了这个远程存储库作为子模块。这个子模块的文件在我建网站的时候用到。在本地,我目前使用以下流程将远程文件合并到我的构建中:
cd public/remote-data
git pull
cd ../..
yarn build
瞧,子模块的文件被烘焙到我的构建中。
现在,我想在 Github Actions 中自动化这个过程,这样每次提交都会触发一个新的构建,其中包含来自远程存储库的最新数据。为此,我尝试使用 checkout 操作中的Checkout multiple repos (nested)功能,并结合一些 yarn 命令来安装依赖项并构建网站:
- name: Checkout tools repo
uses: actions/checkout@v2
with:
repository: remote-org/remote-data
path: public/remote-data
- uses: Borales/actions-yarn@v2.1.0
with:
cmd: install
- uses: Borales/actions-yarn@v2.1.0
with:
cmd: build
但是,当我尝试这样做时,似乎 Github Actions 的整个上下文都转移到了远程存储库。因此,以下yarn install
命令yarn build
无法按预期工作,因为它们需要正确的文件夹上下文才能正常工作。
那么我的问题是:使用 Github Actions,我如何在我自己的存储库的构建过程中使用远程存储库的最新版本?
PS。如果您觉得使用结帐操作不是要走的路,请随意建议另一种方法来达到想要的结果。
解决方案
使用以下步骤签出带有子模块的存储库:
- name: Checkout
uses: actions/checkout@v2
with:
# Whether to checkout submodules: `true` to checkout submodules or `recursive` to
# recursively checkout submodules.
submodules: true
推荐阅读
- xcode - 如何在 Xcode 中渲染具有半透明纹理的 3D 模型?
- c++ - 为什么我看不到字符串?
- docker - 错误:在 Jenkins 中获取远程 repo 'origin'
- overriding - Prestashop 1.7 覆盖 CmsController
- python-3.x - 无法在嵌套表中的 Python Selenium 中使用 CSS 选择器引用元素
- javascript - JS中的递归函数问题
- python - python/tkinter 屏幕停止显示画布更新
- android - Android - 在 EditText 中格式化电话号码
- python - Groupby 中的每个项目
- perl - perl 模块 Class::HPLOO v0.23 安装问题 #2