4

Every time I push a commit to the submodule I need to update the parent repo to the latest commit in the submodule. Is there any automatic way to do that in the remote?

Every time push a commit in the submodule repo i want the parent to automatically point to the latest commit of the child repo. Please suggest if its possible and how?

2 Answers2

4

Using gitlab-ci in the submodule, I was able to trigger the parent to automatically update the master branch in parent when a merge request for the submodule master branch is completed.

stages:
  - build

build_job_dev:
  stage: build
  variables:
    PLUGIN_NAME: coppercrm  
  trigger:
    project: Plugins/parent
    branch: development
  only: 
    - master

I hope this could help someone who is looking for updating parent repo whenever a submodule updates

vvvvv
  • 25,404
  • 19
  • 49
  • 81
  • If I understand that correctly, this only triggers the parents repo pipeline. How do you update (and maybe also commit) the submodules in the parent? – xxtesaxx Sep 15 '21 at 05:41
0

If you have control over your GitLab server, you might consider a post-receive hook (a custom hook) associated to your remote submodule repository, which would:

  • go to a checked-out parent repository
  • execute git submodule update --remote: that would update all submodules to their latest master (by default) commit.
  • add, commit, and push

But if it is gitlab.com, the process becomes more convoluted and will involve a webhook.
That means you will have to implement/install a listener which will do the same operations whenever a push event to your remote submodule repository is triggered.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250