My repository includes a submodule, the submodule is a private repository.
Whenever a push happens, a test-script is executed using GitHub actions.
When GitHub actions updates the submodule, it runs into an authentication problem and cannot access the submodule with GitHub actions.
I followed the discussion on how to authenticate to private repositories, here and here.
Currently, my main issue is how to access and use the personal access token as discussed in the links above.
One of discussion contributors uses a secret.GITHUB_PAT
variable, the other one uses secret.CI_PAT
.
Following this github documentation, there might be a secret.GITHUB_TOKEN
but I have no idea how they created the other two.
-> Are they all the same? How do I create these variables and how do I get my correct PAT put into these variables?
Naively running the code from Lauszus reply gives me the following error.
My Code
assuming SUBREPO
is the submodule,
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
Output
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…