Github action not pulling dependant submodules

I am having a problem with pulling a submodule in the repo of an action when I run that action in other repos.


I have an action repo: which pulls another repo into lib/ which is copied into the dockerfile this then passes all internal tests as I have the checkout option running with submodules on.

If I then try to run this action on a different repo: it fails, due to the setup for the action not pulling the dependancy into lib/, resulting in the dockerfile copying the empy lib directory into the docker container.

Is there a way around this? Can I set up the pull of the action to also pull submodules of the action?

1 Like

The following description from the documentation of Git - Submodules can explain the problem you are facing:

When cloning or checking out a project with Submodules, by default you will get the directories that contain submodules, but none of the files within them yet. The Submodules directory is there, but empty. You must run two commands: git submodule init to initialize your local configuration file, and git submodule update to fetch all the data from that project and check out the appropriate commit listed in your superproject.

As a workaround, maybe you can try to add the git commands for checking out the Submodules into your action, so that it can check out the Submodules at the beginning of the action execution, then do other things in the action execution.


So I made this work by cloning the https endpoint of the current repository in the dockerfile then copying the files the correct location, and the action works as expected.

Currently I have the repository URL hardcoded, wuich works for current master, but feels bad. Is this the way you were thinking I would implement this? Is there a way to pass arguments when building the Dockerfile?

Is handling files within submodules automatically on any product timelines?

If you want to still store the resource files of the submodule in a different repository, I have a workaround here may be as a reference:

Before the action step, you can add an additional step to clone/download the resource files of the submodule into the action directory, it generally is in _actions folder under the runner working directory.

For example:


1 Like

Just include the following script to your github actions step

 - name: include stub submodule to base repo
   run: git submodule update --init