这个问答式问题的原因:我花了几个小时才能运行它,因为我有一些错别字,并且认为解决方案更加复杂。如果我会在Google或Stackoverflow上找到类似的教程,那么我会检查错别字。
Git存储库设置:
A
-名称:repoA
B
(公共存储库)-名称:repoB
目标:
gradle build
中运行repository A > Github Actions
Github操作工作流程
name: Test
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
问题:
actions/checkout@v1
步骤无法访问子模块.gitmodules
[submodule "library"]
path = library
url = git@github.com:organization/repoB.git
Github操作步骤Build with Gradle
错误
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':repoA:compileReleaseAidl'.
> Could not resolve all task dependencies for configuration ':repoA:releaseCompileClasspath'.
> Could not resolve project :repoBSubmodule1.
Required by:
project :repoA
我尝试过的事情:
with: submodules: true
添加到actions/checkout@v1
- uses: actions/checkout@v1
with:
submodules: true
Github操作步骤Run actions/checkout@v1
错误
(...)
git submodule sync
git -c http.https://github.com.extraheader="AUTHORIZATION: basic ***" submodule update --init --force
Submodule 'repoB' (git@github.com:organization/repoB.git) registered for path 'repoB'
Cloning into '/home/runner/work/repoA/repoA/repoB'...
Host key verification failed.
##[error]fatal: Could not read from remote repository.
textbook/git-checkout-submodule-action@2.0.0
之类的第三方Github操作运行教科书/git-checkout-submodule-action@2.00错误:
fatal: Not a git repository (or any parent up to mount point /github/workspace)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
##[error]Docker run failed with exit code 128
向actions/checkout
repo
权限 - uses: actions/checkout@v1
with:
submodules: true
token: ${{ secrets.GITHUB_REPO_TOKEN }}
运行操作/结帐@ v1错误:
git submodule sync
git -c http.https://github.com.extraheader="AUTHORIZATION: basic ***" submodule update --init --force
Submodule 'repoB' (git@github.com:organization/repoB.git) registered for path 'repoB'
Cloning into '/home/runner/work/repoA/repoA/repoB'...
Host key verification failed.
##[error]fatal: Could not read from remote repository.
即使用那个可以访问repoA和repoB的令牌,我什至无法签出上级repoA。
答案 0 :(得分:4)
现在您可以使用action / checkout @ v2
https://github.com/actions/checkout#checkout-submodules说:
- uses: actions/checkout@v2 # checkout root
- name: Checkout submodules # checkout rest
shell: bash
run: |
# If your submodules are configured to use SSH instead of HTTPS please uncomment the following line
# git config --global url."https://github.com/".insteadOf "git@github.com:"
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
答案 1 :(得分:0)
将子模块URL从SSH更改为HTTPS格式即可对其进行修复:
.gitmodules
[submodule "repoB"]
path = repoB
#Before:
url = git@github.com:organization/repoB.git
# After:
url = https://github.com/organization/repoB.git