I've got a repository with a submodule and I'm creating a build when I push to certain branches or tags. The problem I have is that my checkout step cannot access my submodule. The setup is:
I've tried using the GitHub Action actions/checkout@v2
to no avail. As can be seen below I've tried using the 'ssh-key' option where I've added the public key to the the submodules repositories deploy keys and the private key to the secrets of the repository where I run the action. I get the following error messages:
Fetching the repository
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin __myrepo__
ERROR: Repository not found.
Error: fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
The process '/usr/bin/git' failed with exit code 128
Waiting 13 seconds before trying again
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin __myrepo__
ERROR: Repository not found.
Error: fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
The process '/usr/bin/git' failed with exit code 128
Waiting 19 seconds before trying again
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin __myrepo__
ERROR: Repository not found.
Error: fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Error: The process '/usr/bin/git' failed with exit code 128
I've tried with and without the ssh-key
as well as with true
and recursive
option on submodules
. The destination of the submodule is in a directory called src
. The checkout step in my workflow is the following:
Step-01:
runs-on: ubuntu-18.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: 'true'
ssh-key: ${{ secrets.PRIVATE_KEY_FOR_DEPLOY_KEY_IN_SUBMODULE }}
The .gitmodules is:
[submodule "name"]
path = src/name
url = [email protected]:user/repository.git
branch = master
I'm very new to GitHub Actions (CI/CD overall) and not super comfortable with submodules so I may very well have made some basic mistakes.
Pulling with submodules. Once you have set up the submodules you can update the repository with fetch/pull like you would normally do. To pull everything including the submodules, use the --recurse-submodules and the --remote parameter in the git pull command .
Checkout V3 This action checks-out your repository under $GITHUB_WORKSPACE , so your workflow can access it. Only a single commit is fetched by default, for the ref/SHA that triggered the workflow. Set fetch-depth: 0 to fetch all history for all branches and tags.
A git submodule is a record within a host git repository that points to a specific commit in another external repository. Submodules are very static and only track specific commits. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated.
I finally got it working, completely thanks to this.
To clarify the situation SAML SSO is enforced. So instead of using SSH to try and access the submodule I used a personal access token (PAT) where the SSO has been authorized.
What I did:
Step-01:
runs-on: ubuntu-18.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: 'true'
token: ${{ secrets.PAT_TOKEN }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With