如何解决在 github 操作中更新私有子模块时出现身份验证问题
我的仓库包含一个子模块,子模块是一个私有仓库。 每当推送发生时,都会使用 GitHub 操作 执行测试脚本。 当 GitHub 操作 更新子模块时,会遇到身份验证问题,无法使用 GitHub 操作访问子模块。
我关注了关于如何对私有存储库进行身份验证的讨论,here 和 here。
目前,我的主要问题是如何访问和使用上面链接中讨论的个人访问令牌。
讨论贡献者之一使用 secret.GITHUB_PAT
变量,另一个使用 secret.CI_PAT
。
在 this github documentation 之后,可能有一个 secret.GITHUB_TOKEN
,但我不知道他们是如何创建另外两个的。
-> 它们都一样吗?如何创建这些变量以及如何将正确的 PAT 放入这些变量中?
天真地运行 Lauszus reply 中的代码给了我以下错误。
我的代码
假设 SUBREPO
是子模块,
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout reposistory
uses: actions/checkout@v2
- name: Checkout submodule
run: |
git config --file=.gitmodules SUBREPO.url https://${{ secrets.GITHUB_TOKEN }}:${{ secrets.GITHUB_TOKEN }}@github.com/COMP/SUBREPO.git
git submodule sync
git submodule update --init --recursive
输出
Run git config --file=.gitmodules SUBREPO.url ***github.com/COMP/SUBREPO.git
git config --file=.gitmodules SUBREPO.url ***github.com/COMP/SUBREPO.git
git submodule sync
git submodule update --init --recursive
shell: /bin/bash -e {0}
Submodule 'SUBREPO' (https://github.com/COMP/SUBREPO.git) registered for path 'MYREPO/SUBREPO'
Cloning into '/home/runner/work/MYREPO/MYREPO/MYREPO/SUBREPO'...
fatal: could not read Username for 'https://github.com': No such device or address
fatal: clone of 'https://github.com/COMP/SUBREPO.git' into submodule path '/home/runner/work/MYREPO/MYREPO/MYREPO/SUBREPO' failed
Failed to clone 'MYREPO/SUBREPO'. Retry scheduled
Cloning into '/home/runner/work/MYREPO/MYREPO/MYREPO/SUBREPO'...
fatal: could not read Username for 'https://github.com': No such device or address
fatal: clone of 'https://github.com/COMP/SUBREPO.git' into submodule path '/home/runner/work/MYREPO/MYREPO/MYREPO/SUBREPO' failed
Failed to clone 'MYREPO/SUBREPO' a second time,aborting
Error: Process completed with exit code 1.
解决方法
我的主要问题是来自 GitHub 的秘密,可以在存储库中的设置中找到,请参阅附图 secret setting。我将我的 PAT 添加为名为
我进一步更新了我的代码以使用我的 PAT,如下所示,
GitHub 操作的子模块代码部分
uses: actions/checkout@v2.0.0
with:
token: '${{ secrets.<PAT> }}'
repository: <COMP>/<SUBMOD>
path: <relative_path_to_submod>
ref: '<branch>'
工作流输出结束
From https://github.com/<COMP>/<SUBMOD>
* [new branch] <branch> -> origin/<branch>
/usr/bin/git branch --list --remote origin/<branch> origin/<branch>
/usr/bin/git checkout --progress --force -B <branch> refs/remotes/origin/<branch>
Switched to a new branch '<branch>'
Branch '<branch>' set up to track remote branch '<branch>' from 'origin'.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。