Deploying Private Git Submodules on Railway
Deploying Private Git Submodules on Railway
The Problem
I wanted to manage a side project as a git submodule inside FlamelForge, but Railway does not natively support git submodules.
Railway's Nixpacks build environment copies only source files into /app without the .git folder. This means running git submodule update --init during the build always fails with "not a git repository". Using a Dockerfile doesn't help either — Railway still doesn't include .git in the build context.
The fallback of cloning directly in build.sh with git clone was also ruled out because the side project is a private repository, which requires authentication that isn't available in the build environment.
Solution: GitHub Actions Flatten
Instead of downloading the submodule at build time, the approach is to pre-process the code before deployment — converting the submodule into regular files and pushing them to a dedicated deploy branch.
A workflow_dispatch (manually triggered) GitHub Actions workflow handles the following:
- Checkout FlamelForge including submodules (
submodules: recursive) using a PAT with access to both repos - Remove
.gitmodulesand the.gitfolder inside the submodule directory (flatten) - Remove the submodule gitlink from the git index and re-add the files as regular tracked files
- Force push the result to a
railway-deploybranch
Railway is pointed at railway-deploy instead of main. Since the side project's code lives there as plain files, Railway builds without needing any authentication or git operations.
Update Flow
# 1. Push changes to the side project repo
# 2. Update the submodule pointer in FlamelForge
git add src/projects/[project_name]
git commit -m "chore: update [project_name]"
git push
# 3. Manually trigger "Deploy to Railway" from GitHub Actions
Version control is explicit — the submodule pointer (commit hash) in FlamelForge's main branch determines which version of the side project gets deployed. Nothing is reflected in production until the workflow is manually triggered.