I'm in the process of setting up a deployment script. The basic process is:
- Push changes to a bare repository on the server
- Then based on new tags will create a new folder for the release.
- Use git archive to move the files into the release directory
- Runs some migrations scripts and puts it live (if all is successful).
The issue is my repository contains a submodule, which doesn't get put in the archive, and therefore doesn't get put in the release directory.
I've seen git-archive-all, but that doesn't work on a bare repository.
If its not possible, I'm considering,
- making the repository not bare, and updating the working copy, which would allow me to use git-archive-all. Or
- having a second bare repository of the submodule on the server, which I could get an archive from (would have to look into this to make sure I'm getting the right revision).
I use this python package https://github.com/Kentzo/git-archive-all. You can install it by using
On OSX, you can install it also using
brew install git-archive-all
If your submodule is in a repo accessible from the server, I would rather have a post-receive hook which would
git submodule update --init
)git archive
from that second repo (you would be sure to get the right version since the non-bare repo would reference the right version of the submodule)Since the non-bare repo would contain the parent repo and its submodules,
git archive-all
would be able to detect the.git
subdirectories and would archive everything.If the submodule isn't accessible from the server, that means:
Here it is as a few-liner:
Run the following after the regular archive command:
git submodule foreach 'cd REPO_ROOT/$path && git archive HEAD | tar -x -C TARGET_ROOT/$path'
Here the REPO_ROOT is where your repo stands and the TARGET_ROOT is where you put your archived version. (I assume that you have a TARGET_ROOT folder where the expanded version of the first
git archive
call. If you want a final zip/tar, you can tar/zip the final folder)git submodule foreach
provides the$path
variable. Seegit help submodule
foreach section for more details.This should do the trick: https://github.com/meitar/git-archive-all.sh/wiki