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

前端 未结 2 588
野趣味
野趣味 2020-12-17 20:42

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/aft

2条回答
  •  庸人自扰
    2020-12-17 21:23

    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
    

提交回复
热议问题