Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
659 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...