Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
657 views
in Technique[技术] by (71.8m points)

deployment - How can I auto-deploy my git repo's submodules on push?

I have a PHP Cartridge that is operating normally, except I can't find a straightforward way to get OpenShift to (recursively) push the files for my git submodules when/after it pushes my core repo files.

This seems like it should be a super straightforward and common use-case. Am I overlooking something?

I could probably ssh into my server and pull them manually, but I'd like to automate this completely, so that if I update the submodule's reference in my repo these changes will be reflected when I deploy.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For a parent repo (which contains submodules), you should only have to push the parent repo itself: it includes the gitlink (special entries in the index) referencing the right SHA1 for each submodule.

Once pushed, a post-receive hook can trigger a:

git submodule update --init --recursive

That would update each submodule to the right SHA1.

The post-receive hook is in the parent bare repo: /path/to/parent.git/hooks/post-receive with:

#! /bin/bash
cd /path/to/non-bare/parent
git --git-dir=/path/to/parent.git checkout 
git --git-dir=/path/to/parent.git submodule update --init --recursive

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...