【发布时间】:2021-04-16 06:38:42
【问题描述】:
我的存储库包含一个子模块,该子模块是一个私有存储库。 每当推送发生时,都会使用 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 git-submodules github-actions