This was extremely helpful, thank you!
How to use Git SubModules with Forge
This is not a question, but some troubleshooting steps in case someone also experiences difficulties with git submodules in their deployment process. This is not necessarily Forge-specific, but since I encountered this using Forge, I wanted to share the steps I took to rectify the situation.
There may not be anything terribly difficult using submodules with Forge (if you happen to set it up correctly the first time). However, if you by chance set them up incorrectly, it is a (down)right pain to get right again. Here are the things you need to watch out for:
- Update your deploy script on forge to update any submodules:
cd /home/forge/myWebSite
git pull origin develop
git submodule init //initialize submodules
git submodule update //update submodules
composer install
php artisan migrate --force
- Make sure you have the same Forge deploy key added to both the main repository, as well as the original submodule repository.
- Always use SSH urls for your repository and submodules, in the following format:
ssh://git@gitprovider.com/username/repo-slug.git. - Verify this is that case in your local repos, as well as on forge. You will have to manually edit your
/home/forge/site/.git/configfile to make sure the [submodule "path/to/submodule"] url attribute is set using the above-mentioned URL format. - Verify the submodule URL in
/home/forge/project/.gitmodulesfile as well.
Once those are set, you should be able to pull submodules along with your repo using the normal deployment process in the Forge UI.
Please or to participate in this conversation.